Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 64d8f7ee2d | |||
| d8b3aee9dc | |||
| fce94fa4bf | |||
| 254d671629 | |||
| e66e7e627a |
+1
-2
@@ -41,8 +41,7 @@ build:
|
|||||||
"1.19.4", "1.19.2",
|
"1.19.4", "1.19.2",
|
||||||
"1.18.2",
|
"1.18.2",
|
||||||
"1.17.1",
|
"1.17.1",
|
||||||
"1.16.5",
|
"1.16.5"
|
||||||
"1.12.2"
|
|
||||||
]
|
]
|
||||||
script:
|
script:
|
||||||
# this both runs the unit tests and assembles the code
|
# this both runs the unit tests and assembles the code
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="distant-horizons [cleanroom:runClient]" type="GradleRunConfiguration" factoryName="Gradle">
|
|
||||||
<ExternalSystemSettings>
|
|
||||||
<option name="executionName" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="externalSystemIdString" value="GRADLE" />
|
|
||||||
<option name="scriptParameters" value="" />
|
|
||||||
<option name="taskDescriptions">
|
|
||||||
<list />
|
|
||||||
</option>
|
|
||||||
<option name="taskNames">
|
|
||||||
<list>
|
|
||||||
<option value="cleanroom:runClient" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="vmOptions" />
|
|
||||||
</ExternalSystemSettings>
|
|
||||||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
|
|
||||||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
|
||||||
<ExternalSystemDebugDisabled>false</ExternalSystemDebugDisabled>
|
|
||||||
<DebugAllEnabled>false</DebugAllEnabled>
|
|
||||||
<RunAsTest>false</RunAsTest>
|
|
||||||
<GradleProfilingDisabled>false</GradleProfilingDisabled>
|
|
||||||
<GradleCoverageDisabled>false</GradleCoverageDisabled>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
+2
-7
@@ -3,11 +3,12 @@ plugins {
|
|||||||
id 'io.github.pacifistmc.forgix' version '2.+'
|
id 'io.github.pacifistmc.forgix' version '2.+'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false) // TODO vulkan don't run if there is only one mod loader
|
||||||
forgix {
|
forgix {
|
||||||
|
autoRun = true
|
||||||
|
|
||||||
// add the mod loaders to the end of the jar
|
// add the mod loaders to the end of the jar
|
||||||
// put together in the format: "a", "a-b", "a-b-c"
|
// put together in the format: "a", "a-b", "a-b-c"
|
||||||
int loaderCount = 0;
|
|
||||||
String modLoaders = "";
|
String modLoaders = "";
|
||||||
((String) gradle.builds_for)
|
((String) gradle.builds_for)
|
||||||
.split(",")
|
.split(",")
|
||||||
@@ -20,13 +21,7 @@ forgix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modLoaders += loaderName;
|
modLoaders += loaderName;
|
||||||
|
|
||||||
loaderCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// run if there are multiple launchers that need merging
|
|
||||||
autoRun = (loaderCount > 1);
|
|
||||||
|
|
||||||
// merged jars are named in the format:
|
// merged jars are named in the format:
|
||||||
// "DistantHorizons-3.0.1-b-dev-26.1-fabric-neoforge.jar"
|
// "DistantHorizons-3.0.1-b-dev-26.1-fabric-neoforge.jar"
|
||||||
archiveClassifier = modLoaders
|
archiveClassifier = modLoaders
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import org.apache.tools.zip.ZipOutputStream
|
|||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
import java.util.function.Function
|
import java.util.function.Function
|
||||||
import java.util.function.Predicate
|
import java.util.function.Predicate
|
||||||
import groovy.json.JsonSlurper
|
|
||||||
|
|
||||||
// Convention plugin for all MC-facing subprojects (common + loaders).
|
// Convention plugin for all MC-facing subprojects (common + loaders).
|
||||||
// Common uses this directly; loaders use it via unimined-fabric/forge/neoforge.
|
// Common uses this directly; loaders use it via unimined-fabric/forge/neoforge.
|
||||||
@@ -24,9 +23,6 @@ plugins {
|
|||||||
|
|
||||||
def isNotCommonProject = project.name != "common"
|
def isNotCommonProject = project.name != "common"
|
||||||
|
|
||||||
if (isNotCommonProject) {
|
|
||||||
evaluationDependsOn(":common")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== Version Properties ====================
|
// ==================== Version Properties ====================
|
||||||
|
|
||||||
@@ -125,15 +121,6 @@ if (isNotCommonProject) {
|
|||||||
'Multi-Release': true,
|
'Multi-Release': true,
|
||||||
'Main-Class': 'com.seibel.distanthorizons.core.jar.JarMain',
|
'Main-Class': 'com.seibel.distanthorizons.core.jar.JarMain',
|
||||||
)
|
)
|
||||||
if (project.name == "cleanroom") {
|
|
||||||
attributes(
|
|
||||||
'ModType': 'CRL',
|
|
||||||
'MixinConfigs': "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json",
|
|
||||||
'FMLCorePlugin': 'com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin',
|
|
||||||
'FMLCorePluginContainsFMLMod': true,
|
|
||||||
'FMLAT': "src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,14 +133,8 @@ unimined.minecraft(sourceSets.main, true) {
|
|||||||
|
|
||||||
if (gradle.ext.minecraft_version.startsWith("1.")) { // 26.1+ doesn't use obfuscation
|
if (gradle.ext.minecraft_version.startsWith("1.")) { // 26.1+ doesn't use obfuscation
|
||||||
mappings {
|
mappings {
|
||||||
if(gradle.ext.minecraft_version.startsWith("1.12.2")){
|
mojmap()
|
||||||
mcp("stable", "39-1.12")
|
devNamespace "mojmap"
|
||||||
}
|
|
||||||
else{
|
|
||||||
mojmap()
|
|
||||||
devNamespace "mojmap"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,22 +165,18 @@ if (isNotCommonProject) {
|
|||||||
source(project(":common").sourceSets.main.allSource)
|
source(project(":common").sourceSets.main.allSource)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Common: fabric for compilation + access widener, no jar remapping or runs
|
||||||
unimined.minecraft {
|
unimined.minecraft {
|
||||||
if (gradle.ext.minecraft_version.equals("1.12.2")) {
|
fabric {
|
||||||
cleanroom {
|
loader gradle.ext.fabric_loader_version
|
||||||
loader gradle.ext.cleanroom_loader_version
|
accessWidener project.file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons.accesswidener")
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fabric {
|
|
||||||
loader gradle.ext.fabric_loader_version
|
|
||||||
accessWidener project.file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons.accesswidener")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defaultRemapJar = false
|
defaultRemapJar = false
|
||||||
runs.off = true
|
runs.off = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ==================== Configurations ====================
|
// ==================== Configurations ====================
|
||||||
|
|
||||||
evaluationDependsOn(":core")
|
evaluationDependsOn(":core")
|
||||||
@@ -369,25 +346,12 @@ if (isNotCommonProject) {
|
|||||||
def loaderPaths = configurations.minecraftLibraries.resolve().collect { it.path }.toSet()
|
def loaderPaths = configurations.minecraftLibraries.resolve().collect { it.path }.toSet()
|
||||||
tasks.withType(JavaExec).configureEach { runTask ->
|
tasks.withType(JavaExec).configureEach { runTask ->
|
||||||
dependsOn(shadowJar)
|
dependsOn(shadowJar)
|
||||||
if (project.name != "cleanroom") {
|
classpath = files(shadowJar.archiveFile) + classpath.filter { file ->
|
||||||
classpath = files(shadowJar.archiveFile) + classpath.filter { file ->
|
!file.path.contains(project.buildDir.path) &&
|
||||||
file != shadowJar.archiveFile.get().asFile &&
|
!file.path.contains("core${File.separator}build") &&
|
||||||
!file.path.contains(project.buildDir.path) &&
|
!file.path.contains("api${File.separator}build") &&
|
||||||
!file.path.contains("core${File.separator}build") &&
|
!file.path.contains("common${File.separator}build") &&
|
||||||
!file.path.contains("api${File.separator}build") &&
|
!(shadowedPaths.contains(file.path) && !loaderPaths.contains(file.path))
|
||||||
!file.path.contains("common${File.separator}build") &&
|
|
||||||
!(shadowedPaths.contains(file.path) && !loaderPaths.contains(file.path))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// For cleanroom, don't put shadow jar on app classpath.
|
|
||||||
// crl.dev.extrapath loads it via LaunchClassLoader instead.
|
|
||||||
classpath = classpath.filter { file ->
|
|
||||||
!file.path.contains(project.buildDir.path) &&
|
|
||||||
!file.path.contains("core${File.separator}build") &&
|
|
||||||
!file.path.contains("api${File.separator}build") &&
|
|
||||||
!file.path.contains("common${File.separator}build") &&
|
|
||||||
!(shadowedPaths.contains(file.path) && !loaderPaths.contains(file.path))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shared run directory so all loaders use the same worlds
|
// Shared run directory so all loaders use the same worlds
|
||||||
@@ -403,28 +367,20 @@ if (isNotCommonProject) {
|
|||||||
}
|
}
|
||||||
runTask.jvmArgs = filteredArgs
|
runTask.jvmArgs = filteredArgs
|
||||||
|
|
||||||
if(project.name == "forge"
|
// fix (Neo)forge debug running
|
||||||
|| project.name == "neoforge"
|
doFirst {
|
||||||
|| project.name == "cleanroom")
|
def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods")
|
||||||
{
|
modsDir.mkdirs()
|
||||||
// fix (Neo)forge, Cleanroom debug running
|
|
||||||
doFirst {
|
|
||||||
def modsDir = rootProject.file("run/${isClient ? 'client' : 'server'}/mods")
|
|
||||||
modsDir.mkdirs()
|
|
||||||
|
|
||||||
// Remove any stale DH jars before copying the fresh one
|
// Remove any stale DH jars before copying the fresh one
|
||||||
modsDir.listFiles()?.each({ file ->
|
modsDir.listFiles()?.each { file ->
|
||||||
if (file.name.startsWith(rootProject.mod_name))
|
if (file.name.startsWith(rootProject.mod_name)) file.delete()
|
||||||
{
|
}
|
||||||
file.delete()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Copy shadow jar into mods folder so (Neo)Forge discovers it properly
|
// Copy shadow jar into mods folder so (Neo)Forge discovers it properly
|
||||||
copy {
|
copy {
|
||||||
from shadowJar.archiveFile
|
from shadowJar.archiveFile
|
||||||
into modsDir
|
into modsDir
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,10 +418,6 @@ if (isNotCommonProject) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.downgradeJar.inputFile.set(tasks.named("remapJar").flatMap { it.archiveFile })
|
|
||||||
tasks.jar.finalizedBy(tasks.named("remapJar"))
|
|
||||||
tasks.named("remapJar").configure { finalizedBy(tasks.shadeDowngradedApi) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,7 +429,6 @@ if (isNotCommonProject) {
|
|||||||
def resourceTargets = [
|
def resourceTargets = [
|
||||||
"build_info.json",
|
"build_info.json",
|
||||||
"fabric.mod.json",
|
"fabric.mod.json",
|
||||||
"mcmod.info",
|
|
||||||
"quilt.mod.json",
|
"quilt.mod.json",
|
||||||
"META-INF/mods.toml",
|
"META-INF/mods.toml",
|
||||||
"META-INF/neoforge.mods.toml",
|
"META-INF/neoforge.mods.toml",
|
||||||
@@ -488,7 +439,6 @@ if (isNotCommonProject) {
|
|||||||
// Quilt contributors
|
// Quilt contributors
|
||||||
def quilt_contributors = []
|
def quilt_contributors = []
|
||||||
def mod_author_list = rootProject.mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
|
def mod_author_list = rootProject.mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
|
||||||
def cleanroom_author_list = rootProject.mod_authors.replace('[', '').replace(']', '').split(',').collect({ it.trim().replace('"', '') }).join('", "')
|
|
||||||
for (dev in mod_author_list) {
|
for (dev in mod_author_list) {
|
||||||
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
|
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
|
||||||
}
|
}
|
||||||
@@ -506,11 +456,9 @@ if (isNotCommonProject) {
|
|||||||
|
|
||||||
def replaceProperties = [
|
def replaceProperties = [
|
||||||
version : rootProject.mod_version,
|
version : rootProject.mod_version,
|
||||||
mod_id : rootProject.mod_id,
|
|
||||||
mod_name : rootProject.mod_readable_name,
|
mod_name : rootProject.mod_readable_name,
|
||||||
group : rootProject.maven_group,
|
group : rootProject.maven_group,
|
||||||
authors : rootProject.mod_authors,
|
authors : rootProject.mod_authors,
|
||||||
cleanroom_authors : cleanroom_author_list,
|
|
||||||
description : rootProject.mod_description,
|
description : rootProject.mod_description,
|
||||||
homepage : rootProject.mod_homepage,
|
homepage : rootProject.mod_homepage,
|
||||||
source : rootProject.mod_source,
|
source : rootProject.mod_source,
|
||||||
@@ -528,7 +476,6 @@ if (isNotCommonProject) {
|
|||||||
fabric_incompatibility_list : rootProject.fabric_incompatibility_list,
|
fabric_incompatibility_list : rootProject.fabric_incompatibility_list,
|
||||||
fabric_recommend_list : rootProject.fabric_recommend_list,
|
fabric_recommend_list : rootProject.fabric_recommend_list,
|
||||||
neoforge_version_range : rootProject.neoforge_version_range,
|
neoforge_version_range : rootProject.neoforge_version_range,
|
||||||
logo_path : "assets/distanthorizons/icon.png"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
inputs.properties replaceProperties
|
inputs.properties replaceProperties
|
||||||
@@ -539,7 +486,7 @@ if (isNotCommonProject) {
|
|||||||
|
|
||||||
// Remove unused access wideners
|
// Remove unused access wideners
|
||||||
exclude { file ->
|
exclude { file ->
|
||||||
if ((file.name.contains(".distanthorizons.accesswidener") && file.name != "${rootProject.accessWidenerVersion}.distanthorizons.accesswidener")) {
|
if (file.name.contains(".distanthorizons.accesswidener") && file.name != "${rootProject.accessWidenerVersion}.distanthorizons.accesswidener") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@@ -560,25 +507,6 @@ if (isNotCommonProject) {
|
|||||||
into project.file("build/resources/main")
|
into project.file("build/resources/main")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("convertJsonToLang") {
|
|
||||||
dependsOn(copyCoreResources)
|
|
||||||
|
|
||||||
File input = project.file("build/resources/main/assets/distanthorizons/lang/en_us.json")
|
|
||||||
File output = project.file("build/resources/main/assets/distanthorizons/lang/en_us.lang")
|
|
||||||
inputs.file(input)
|
|
||||||
outputs.file(output)
|
|
||||||
doLast {
|
|
||||||
output.withWriter("UTF-8") { writer ->
|
|
||||||
writer.writeLine("#PARSE_ESCAPES")
|
|
||||||
new JsonSlurper()
|
|
||||||
.parse(input)
|
|
||||||
.each { key, value ->
|
|
||||||
writer.writeLine("${key}=${value.toString().replace("%", "%%").replace("\n", "\\n")}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ==================== JVMDowngrader ====================
|
// ==================== JVMDowngrader ====================
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'dh-loader'
|
|
||||||
}
|
|
||||||
|
|
||||||
unimined.minecraft {
|
|
||||||
cleanroom {
|
|
||||||
loader gradle.ext.cleanroom_loader_version
|
|
||||||
useToolchains = false
|
|
||||||
accessTransformer project(":common").file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg")
|
|
||||||
runs.all {
|
|
||||||
systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json")
|
|
||||||
systemProperty("fml.coreMods.load", "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'unimined-cleanroom'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ==================== Mod Dependency Helper ====================
|
|
||||||
|
|
||||||
def addMod(path, enabled) {
|
|
||||||
if (enabled == "2")
|
|
||||||
dependencies { modImplementation(path) }
|
|
||||||
else if (enabled == "1")
|
|
||||||
dependencies { compileOnly(path) }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ==================== Dependencies ====================
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ==================== Tasks ====================
|
|
||||||
|
|
||||||
task deleteResources(type: Delete) {
|
|
||||||
delete file("build/resources/main")
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
rename '(.+_at.cfg)', 'META-INF/$1'
|
|
||||||
dependsOn(copyCoreResources)
|
|
||||||
dependsOn(convertJsonToLang)
|
|
||||||
// dependsOn(copyCommonLoaderResources)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named('runClient') {
|
|
||||||
dependsOn(copyCoreResources)
|
|
||||||
// dependsOn(copyCommonLoaderResources)
|
|
||||||
finalizedBy(deleteResources)
|
|
||||||
}
|
|
||||||
|
|
||||||
sourcesJar {
|
|
||||||
def commonSources = project(":common").sourcesJar
|
|
||||||
dependsOn commonSources
|
|
||||||
from commonSources.archiveFile.map { zipTree(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-214
@@ -1,214 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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.FMLCommonHandler;
|
|
||||||
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;
|
|
||||||
|
|
||||||
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);
|
|
||||||
MinecraftForge.EVENT_BUS.register(FMLCommonHandler.instance());
|
|
||||||
CleanroomPluginPacketSender.setPacketHandler(ClientApi.INSTANCE::pluginMessageReceived);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
|
||||||
// chunk events //
|
|
||||||
//==============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
|
||||||
// key bindings //
|
|
||||||
//==============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
@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());*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===========//
|
|
||||||
// rendering //
|
|
||||||
//===========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
@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());
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.cleanroom;
|
|
||||||
|
|
||||||
import com.seibel.distanthorizons.cleanroom.modAccessor.ModChecker;
|
|
||||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
|
||||||
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.InternalServerGenerator;
|
|
||||||
import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.common.event.*;
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
import org.apache.logging.log4j.core.config.Configurator;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize and setup the Mod. <br>
|
|
||||||
* 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 preinit(FMLPreInitializationEvent event)
|
|
||||||
{
|
|
||||||
Configurator.setLevel("org.sqlite", Level.INFO);
|
|
||||||
ForgeChunkManager.setForcedChunkLoadingCallback(CleanroomMain.instance, (tickets, world) -> { });
|
|
||||||
}
|
|
||||||
|
|
||||||
@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<CommandDispatcher<CommandSourceStack>> 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 onServerStarting(FMLServerStartingEvent event)
|
|
||||||
{
|
|
||||||
event.registerServerCommand(CommandInitializer.initCommands());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
public void onServerAboutToStart(FMLServerAboutToStartEvent event)
|
|
||||||
{
|
|
||||||
if (eventHandlerStartServer != null)
|
|
||||||
{
|
|
||||||
eventHandlerStartServer.accept(event.getServer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Consumer<MinecraftServer> eventHandlerStartServer;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void subscribeServerStartingEvent(Consumer<MinecraftServer> 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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<AbstractNetworkMessage> consumer)
|
|
||||||
{ setPacketHandler((player, message) -> consumer.accept(message)); }
|
|
||||||
static BiConsumer<IServerPlayerWrapper, AbstractNetworkMessage> consumerPacket;
|
|
||||||
public static void setPacketHandler(BiConsumer<IServerPlayerWrapper, AbstractNetworkMessage> 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); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
|
||||||
// helper classes //
|
|
||||||
//================//
|
|
||||||
//region
|
|
||||||
|
|
||||||
// Forge doesn't support using abstract classes
|
|
||||||
@SuppressWarnings({"ClassCanBeRecord", "RedundantSuppression"})
|
|
||||||
public static class MessageWrapper implements IMessage
|
|
||||||
{
|
|
||||||
public AbstractNetworkMessage message;
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
|
||||||
// constructor //
|
|
||||||
//=============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
public MessageWrapper(AbstractNetworkMessage message) { this.message = message; }
|
|
||||||
|
|
||||||
public MessageWrapper()
|
|
||||||
{
|
|
||||||
// For reflection
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
@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<MessageWrapper, IMessage>
|
|
||||||
{
|
|
||||||
@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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
-181
@@ -1,181 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.cleanroom;
|
|
||||||
|
|
||||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
|
||||||
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
|
||||||
import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon;
|
|
||||||
import com.seibel.distanthorizons.common.util.ProxyUtil;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
|
||||||
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.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import static com.seibel.distanthorizons.cleanroom.CleanroomMain.instance;
|
|
||||||
|
|
||||||
public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy
|
|
||||||
{
|
|
||||||
private static final CleanroomPluginPacketSender PACKET_SENDER = (CleanroomPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class);
|
|
||||||
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);
|
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
|
||||||
if (this.isDedicated)
|
|
||||||
{
|
|
||||||
PACKET_SENDER.setPacketHandler(ServerApi.INSTANCE::pluginMessageReceived);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
|
||||||
// constructor //
|
|
||||||
//=============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
public CleanroomServerProxy(boolean isDedicated) { this.isDedicated = isDedicated; }
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//========//
|
|
||||||
// events //
|
|
||||||
//========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
// ServerLevelLoadEvent
|
|
||||||
@SubscribeEvent
|
|
||||||
public void serverLevelLoadEvent(WorldEvent.Load event)
|
|
||||||
{
|
|
||||||
if (GetEventLevel(event) instanceof WorldServer)
|
|
||||||
{
|
|
||||||
this.serverApi.serverLevelLoadEvent(getServerLevelWrapper((WorldServer) GetEventLevel(event)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 serverChunkSaveEvent(ChunkDataEvent.Save event)
|
|
||||||
{
|
|
||||||
if (event.getWorld() instanceof WorldServer worldServer)
|
|
||||||
{
|
|
||||||
MixinChunkMapCommon.onChunkSave(worldServer, event.getChunk());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
|
|
||||||
{ this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); }
|
|
||||||
|
|
||||||
@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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
|
||||||
// helper methods //
|
|
||||||
//================//
|
|
||||||
//region
|
|
||||||
|
|
||||||
private static ServerLevelWrapper getServerLevelWrapper(WorldServer level) { return ServerLevelWrapper.getWrapper(level); }
|
|
||||||
|
|
||||||
private static ServerLevelWrapper getServerLevelWrapper(int dimensionId, PlayerEvent event)
|
|
||||||
{
|
|
||||||
MinecraftServer server = event.player.getServer();
|
|
||||||
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); }
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
-56
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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<String> myTargets, Set<String> otherTargets) { }
|
|
||||||
@Override public List<String> 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) { }
|
|
||||||
|
|
||||||
}
|
|
||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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<String, Object> data) { }
|
|
||||||
@Override
|
|
||||||
public @Nullable String getAccessTransformerClass()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-82
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.cleanroom.mixins.client;
|
|
||||||
|
|
||||||
import com.seibel.distanthorizons.common.commonMixins.MixinVanillaFogCommon;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
MinecraftRenderWrapper renderWrapper = (MinecraftRenderWrapper)SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
|
||||||
renderWrapper.setLightmapId(lightmapTexture.getGlTextureId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "setupFog")
|
|
||||||
private void disableSetupFog(int startCoords, float partialTicks, CallbackInfo ci)
|
|
||||||
{
|
|
||||||
boolean cancelFog = MixinVanillaFogCommon.cancelFog(startCoords, mc);
|
|
||||||
if (cancelFog)
|
|
||||||
{
|
|
||||||
GlStateManager.setFogStart(A_REALLY_REALLY_BIG_VALUE);
|
|
||||||
GlStateManager.setFogEnd(A_EVEN_LARGER_VALUE);
|
|
||||||
ClientApi.RENDER_STATE.vanillaFogEnabled = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ClientApi.RENDER_STATE.vanillaFogEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-83
@@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-81
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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<Integer> 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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-66
@@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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<Entity> cir)
|
|
||||||
{ this.distantHorizons$dimensionChangeDestination = this.server.getWorld(destinationDimensionID); }
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "clearInvulnerableDimensionChange")
|
|
||||||
public void clearDimensionChangeDestination(CallbackInfo ci)
|
|
||||||
{ this.distantHorizons$dimensionChangeDestination = null; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.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<ModContainer> foundStream = Loader.instance().getModList().stream().filter(x -> x.getModId().equals(modid));
|
|
||||||
Optional<ModContainer> container = foundStream.findFirst();
|
|
||||||
if (!container.isPresent())
|
|
||||||
{
|
|
||||||
throw new RuntimeException("Mod not found: " + modid);
|
|
||||||
}
|
|
||||||
return container.get().getSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "com.seibel.distanthorizons.cleanroom.mixins",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"target": "@env(DEFAULT)",
|
|
||||||
"mixins": [],
|
|
||||||
"minVersion": "0.8.7",
|
|
||||||
"server": [
|
|
||||||
"server.MixinEntityPlayerMP"
|
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
"client.MixinEntityRenderer",
|
|
||||||
"client.MixinNetHandlerPlayClient",
|
|
||||||
"client.MixinOptionsScreen",
|
|
||||||
"client.MixinRenderGlobal"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"required": false,
|
|
||||||
"package": "com.seibel.distanthorizons.cleanroom.mixins.mod",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"target": "@env(MOD)",
|
|
||||||
"mixins": [],
|
|
||||||
"minVersion": "0.8.7",
|
|
||||||
"plugin": "com.seibel.distanthorizons.cleanroom.DistantHorizonsConfigPlugin",
|
|
||||||
"client": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[{
|
|
||||||
"modid": "${mod_id}",
|
|
||||||
"name": "${mod_name}",
|
|
||||||
"version": "${version}",
|
|
||||||
"mcversion": "1.12.2",
|
|
||||||
"description": "${description}",
|
|
||||||
"authorList": ["${cleanroom_authors}"],
|
|
||||||
"credits": "",
|
|
||||||
"url": "",
|
|
||||||
"updateJSON": "",
|
|
||||||
"logoFile": "${logo_path}"
|
|
||||||
}]
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"description": "${mod_name} Resources",
|
|
||||||
"pack_format": 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.seibel.distanthorizons.common;
|
package com.seibel.distanthorizons.common;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
||||||
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
||||||
@@ -31,6 +30,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccesso
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
@@ -39,11 +39,6 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base for all mod loader initializers
|
* Base for all mod loader initializers
|
||||||
* and handles most setup.
|
* and handles most setup.
|
||||||
@@ -67,9 +62,7 @@ public abstract class AbstractModInitializer
|
|||||||
protected abstract IEventProxy createServerProxy(boolean isDedicated);
|
protected abstract IEventProxy createServerProxy(boolean isDedicated);
|
||||||
protected abstract void initializeModCompat();
|
protected abstract void initializeModCompat();
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
protected abstract void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler);
|
protected abstract void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler);
|
||||||
#endif
|
|
||||||
|
|
||||||
protected abstract void subscribeClientStartedEvent(Runnable eventHandler);
|
protected abstract void subscribeClientStartedEvent(Runnable eventHandler);
|
||||||
protected abstract void subscribeServerStartingEvent(Consumer<MinecraftServer> eventHandler);
|
protected abstract void subscribeServerStartingEvent(Consumer<MinecraftServer> eventHandler);
|
||||||
@@ -103,7 +96,6 @@ public abstract class AbstractModInitializer
|
|||||||
// Client uses config for auto-updater, so it's initialized here instead of post-init stage
|
// Client uses config for auto-updater, so it's initialized here instead of post-init stage
|
||||||
this.initConfig();
|
this.initConfig();
|
||||||
logIncompatibilityWarnings(); // needs to be called after config loading
|
logIncompatibilityWarnings(); // needs to be called after config loading
|
||||||
setUnsupportedConfigsBasedOnMcVersion();
|
|
||||||
Initializer.postConfigInit();
|
Initializer.postConfigInit();
|
||||||
|
|
||||||
LOGGER.info(ModInfo.READABLE_NAME + " client Initialized.");
|
LOGGER.info(ModInfo.READABLE_NAME + " client Initialized.");
|
||||||
@@ -138,10 +130,8 @@ public abstract class AbstractModInitializer
|
|||||||
this.initializeModCompat();
|
this.initializeModCompat();
|
||||||
|
|
||||||
LOGGER.info(ModInfo.READABLE_NAME + " server Initialized, adding event subscribers...");
|
LOGGER.info(ModInfo.READABLE_NAME + " server Initialized, adding event subscribers...");
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.commandInitializer = new CommandInitializer();
|
this.commandInitializer = new CommandInitializer();
|
||||||
this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); });
|
this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); });
|
||||||
#endif
|
|
||||||
|
|
||||||
this.subscribeServerStartingEvent(server ->
|
this.subscribeServerStartingEvent(server ->
|
||||||
{
|
{
|
||||||
@@ -151,20 +141,11 @@ public abstract class AbstractModInitializer
|
|||||||
Initializer.postConfigInit();
|
Initializer.postConfigInit();
|
||||||
this.postInit();
|
this.postInit();
|
||||||
this.postServerInit();
|
this.postServerInit();
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.commandInitializer.onServerReady();
|
this.commandInitializer.onServerReady();
|
||||||
#endif
|
|
||||||
|
|
||||||
this.checkForUpdates();
|
this.checkForUpdates();
|
||||||
|
|
||||||
String serverFolderPath;
|
LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.getServerDirectory());
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
serverFolderPath = server.getDataDirectory() + "";
|
|
||||||
#else
|
|
||||||
serverFolderPath = server.getServerDirectory() + "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + serverFolderPath);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,24 +393,6 @@ public abstract class AbstractModInitializer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Some Minecraft versions don't support all
|
|
||||||
* DH options.
|
|
||||||
* In that case we need to override what options are available.
|
|
||||||
*/
|
|
||||||
private static void setUnsupportedConfigsBasedOnMcVersion()
|
|
||||||
{
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL);
|
|
||||||
Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.setMcVersionOverrideValue(EDhApiMcRenderingFadeMode.NONE);
|
|
||||||
Config.Common.WorldGenerator.distantGeneratorMode.setMcVersionOverrideValue(EDhApiDistantGeneratorMode.INTERNAL_SERVER);
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL);
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-29
@@ -12,17 +12,10 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSende
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
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.network.FriendlyByteBuf;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
@@ -37,9 +30,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
.fileLevelConfig(Config.Common.Logging.logNetworkEventToFile)
|
.fileLevelConfig(Config.Common.Logging.logNetworkEventToFile)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_20_6
|
||||||
public static final String WRAPPER_PACKET_RESOURCE = ModInfo.RESOURCE_NAMESPACE + ModInfo.WRAPPER_PACKET_PATH;
|
|
||||||
#elif 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 ResourceLocation WRAPPER_PACKET_RESOURCE = new ResourceLocation(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH);
|
||||||
#elif MC_VER <= MC_1_21_10
|
#elif MC_VER <= MC_1_21_10
|
||||||
public static final ResourceLocation WRAPPER_PACKET_RESOURCE = ResourceLocation.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH);
|
public static final ResourceLocation WRAPPER_PACKET_RESOURCE = ResourceLocation.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH);
|
||||||
@@ -61,28 +52,14 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
@Override
|
@Override
|
||||||
public final void sendToClient(IServerPlayerWrapper serverPlayer, AbstractNetworkMessage message)
|
public final void sendToClient(IServerPlayerWrapper serverPlayer, AbstractNetworkMessage message)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.sendToClient((EntityPlayerMP) serverPlayer.getWrappedMcObject(), message);
|
|
||||||
#else
|
|
||||||
this.sendToClient((ServerPlayer) serverPlayer.getWrappedMcObject(), message);
|
this.sendToClient((ServerPlayer) serverPlayer.getWrappedMcObject(), message);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public abstract void sendToClient(EntityPlayerMP serverPlayer, AbstractNetworkMessage message);
|
|
||||||
#else
|
|
||||||
public abstract void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message);
|
public abstract void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void sendToServer(AbstractNetworkMessage message);
|
public abstract void sendToServer(AbstractNetworkMessage message);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public AbstractNetworkMessage decodeMessage(PacketBuffer in)
|
|
||||||
#else
|
|
||||||
public AbstractNetworkMessage decodeMessage(FriendlyByteBuf in)
|
public AbstractNetworkMessage decodeMessage(FriendlyByteBuf in)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
AbstractNetworkMessage message = null;
|
AbstractNetworkMessage message = null;
|
||||||
|
|
||||||
@@ -123,11 +100,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void encodeMessage(PacketBuffer out, AbstractNetworkMessage message)
|
|
||||||
#else
|
|
||||||
public void encodeMessage(FriendlyByteBuf out, AbstractNetworkMessage message)
|
public void encodeMessage(FriendlyByteBuf out, AbstractNetworkMessage message)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// This is intentionally unhandled, because errors related to this are unlikely to appear in wild
|
// This is intentionally unhandled, because errors related to this are unlikely to appear in wild
|
||||||
Objects.requireNonNull(message);
|
Objects.requireNonNull(message);
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package com.seibel.distanthorizons.common.commands;
|
package com.seibel.distanthorizons.common.commands;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public abstract class AbstractCommand {}
|
|
||||||
|
|
||||||
#else
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||||
@@ -104,4 +100,3 @@ public abstract class AbstractCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+3
-81
@@ -1,26 +1,12 @@
|
|||||||
package com.seibel.distanthorizons.common.commands;
|
package com.seibel.distanthorizons.common.commands;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
|
||||||
import com.seibel.distanthorizons.core.config.types.AbstractConfigBase;
|
|
||||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
|
||||||
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
|
||||||
import net.minecraft.command.CommandBase;
|
|
||||||
import net.minecraft.command.ICommand;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
#else
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import static net.minecraft.commands.Commands.literal;
|
|
||||||
#endif
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.seibel.distanthorizons.core.network.messages.MessageRegistry.DEBUG_CODEC_CRASH_MESSAGE;
|
import static com.seibel.distanthorizons.core.network.messages.MessageRegistry.DEBUG_CODEC_CRASH_MESSAGE;
|
||||||
|
import static net.minecraft.commands.Commands.literal;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
#else
|
#else
|
||||||
@@ -39,70 +25,6 @@ public class CommandInitializer
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static ICommand initCommands()
|
|
||||||
{
|
|
||||||
return new CommandBase()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public String getName() { return "dh"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage(ICommandSender sender) { return "/dh <debug|config|pregen>"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length == 0)
|
|
||||||
{
|
|
||||||
if (DEBUG_CODEC_CRASH_MESSAGE)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Usage: /dh <debug|config|crash|pregen>"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Usage: /dh <debug|config|pregen"));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args[0])
|
|
||||||
{
|
|
||||||
case "debug":
|
|
||||||
DebugCommand debugCommand = new DebugCommand();
|
|
||||||
debugCommand.execute(sender);
|
|
||||||
break;
|
|
||||||
case "config":
|
|
||||||
ConfigCommand configCommand = new ConfigCommand();
|
|
||||||
configCommand.execute(sender, args);
|
|
||||||
break;
|
|
||||||
case "crash":
|
|
||||||
if (DEBUG_CODEC_CRASH_MESSAGE)
|
|
||||||
{
|
|
||||||
CrashCommand crashCommand = new CrashCommand();
|
|
||||||
crashCommand.execute(sender, args);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "pregen":
|
|
||||||
if (!server.isDedicatedServer())
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Pregen command is only available on dedicated servers"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
PregenCommand pregenCommand = new PregenCommand();
|
|
||||||
pregenCommand.execute(server, sender, args);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sender.sendMessage(new TextComponentString("Unknown subcommand: " + args[0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A received command dispatcher, which is held until the server is ready to initialize the commands.
|
* A received command dispatcher, which is held until the server is ready to initialize the commands.
|
||||||
*/
|
*/
|
||||||
@@ -158,5 +80,5 @@ public class CommandInitializer
|
|||||||
|
|
||||||
commandDispatcher.register(builder);
|
commandDispatcher.register(builder);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,13 @@
|
|||||||
package com.seibel.distanthorizons.common.commands;
|
package com.seibel.distanthorizons.common.commands;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
|
||||||
import com.seibel.distanthorizons.core.config.types.AbstractConfigBase;
|
|
||||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
#else
|
|
||||||
import com.mojang.brigadier.arguments.*;
|
import com.mojang.brigadier.arguments.*;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||||
|
import com.seibel.distanthorizons.core.config.types.AbstractConfigBase;
|
||||||
|
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
|
||||||
import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg;
|
|
||||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
|
||||||
import static net.minecraft.commands.Commands.argument;
|
|
||||||
import static net.minecraft.commands.Commands.literal;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,75 +16,16 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.function.ToIntBiFunction;
|
import java.util.function.ToIntBiFunction;
|
||||||
|
|
||||||
|
import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg;
|
||||||
|
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||||
|
import static net.minecraft.commands.Commands.argument;
|
||||||
|
import static net.minecraft.commands.Commands.literal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command for managing config.
|
* Command for managing config.
|
||||||
*/
|
*/
|
||||||
public class ConfigCommand extends AbstractCommand
|
public class ConfigCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
||||||
private static void setConfigValue(ConfigEntry<?> configEntry, String value)
|
|
||||||
{
|
|
||||||
Class<?> type = configEntry.getType();
|
|
||||||
|
|
||||||
if (type == Boolean.class) ((ConfigEntry) configEntry).set(Boolean.parseBoolean(value));
|
|
||||||
else if (type == Integer.class) ((ConfigEntry) configEntry).set(Integer.parseInt(value));
|
|
||||||
else if (type == Double.class) ((ConfigEntry) configEntry).set(Double.parseDouble(value));
|
|
||||||
else if (type == Float.class) ((ConfigEntry) configEntry).set(Float.parseFloat(value));
|
|
||||||
else if (type == Long.class) ((ConfigEntry) configEntry).set(Long.parseLong(value));
|
|
||||||
else if (type == String.class) ((ConfigEntry) configEntry).set(value);
|
|
||||||
else if (type.isEnum()) ((ConfigEntry) configEntry).set(Enum.valueOf((Class<Enum>) type, value));
|
|
||||||
else throw new RuntimeException("Unsupported config type: " + type.getSimpleName());
|
|
||||||
}
|
|
||||||
public void execute(ICommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Usage: /dh config <name> [value]"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String configName = args[1];
|
|
||||||
AbstractConfigBase<?> found = null;
|
|
||||||
for (AbstractConfigBase<?> entry : ConfigHandler.INSTANCE.configBaseList)
|
|
||||||
{
|
|
||||||
if (entry instanceof ConfigEntry && configName.equals(((ConfigEntry<?>) entry).getChatCommandName()))
|
|
||||||
{
|
|
||||||
found = entry;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found == null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Unknown config: " + configName));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigEntry<?> configEntry = (ConfigEntry<?>) found;
|
|
||||||
if (args.length == 2)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Current value of " + configName + " is " + configEntry.get()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String value = args[2];
|
|
||||||
try
|
|
||||||
{
|
|
||||||
setConfigValue(configEntry, value);
|
|
||||||
sender.sendMessage(new TextComponentString("Changed " + configName + " to " + value));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Invalid value: " + value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
private static final List<CommandArgumentData<?>> commandArguments = Arrays.asList(
|
private static final List<CommandArgumentData<?>> commandArguments = Arrays.asList(
|
||||||
new CommandArgumentData<>(Integer.class, configEntry -> integer(configEntry.getMin(), configEntry.getMax()), IntegerArgumentType::getInteger),
|
new CommandArgumentData<>(Integer.class, configEntry -> integer(configEntry.getMin(), configEntry.getMax()), IntegerArgumentType::getInteger),
|
||||||
new CommandArgumentData<>(Double.class, configEntry -> doubleArg(configEntry.getMin(), configEntry.getMax()), DoubleArgumentType::getDouble),
|
new CommandArgumentData<>(Double.class, configEntry -> doubleArg(configEntry.getMin(), configEntry.getMax()), DoubleArgumentType::getDouble),
|
||||||
@@ -221,6 +150,5 @@ public class ConfigCommand extends AbstractCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,60 +1,15 @@
|
|||||||
package com.seibel.distanthorizons.common.commands;
|
package com.seibel.distanthorizons.common.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
import com.seibel.distanthorizons.core.multiplayer.server.ServerPlayerState;
|
import com.seibel.distanthorizons.core.multiplayer.server.ServerPlayerState;
|
||||||
import com.seibel.distanthorizons.core.network.messages.base.CodecCrashMessage;
|
import com.seibel.distanthorizons.core.network.messages.base.CodecCrashMessage;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
#else
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|
||||||
|
|
||||||
import static net.minecraft.commands.Commands.literal;
|
import static net.minecraft.commands.Commands.literal;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
public class CrashCommand extends AbstractCommand
|
public class CrashCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void execute(ICommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
if (!(sender instanceof EntityPlayerMP))
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("This command can only be run by a player"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Usage: /dh crash <encode|decode>"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SharedApi.tryGetDhServerWorld() == null) return;
|
|
||||||
|
|
||||||
ServerPlayerState serverPlayerState = SharedApi.tryGetDhServerWorld()
|
|
||||||
.getServerPlayerStateManager()
|
|
||||||
.getConnectedPlayer(ServerPlayerWrapper.getWrapper((EntityPlayerMP) sender));
|
|
||||||
|
|
||||||
if (serverPlayerState == null) return;
|
|
||||||
|
|
||||||
switch (args[1])
|
|
||||||
{
|
|
||||||
case "encode":
|
|
||||||
serverPlayerState.networkSession.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.ENCODE));
|
|
||||||
break;
|
|
||||||
case "decode":
|
|
||||||
serverPlayerState.networkSession.sendMessage(new CodecCrashMessage(CodecCrashMessage.ECrashPhase.DECODE));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sender.sendMessage(new TextComponentString("Usage: /dh crash <encode|decode>"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
@Override
|
@Override
|
||||||
public LiteralArgumentBuilder<CommandSourceStack> buildCommand()
|
public LiteralArgumentBuilder<CommandSourceStack> buildCommand()
|
||||||
{
|
{
|
||||||
@@ -85,6 +40,5 @@ public class CrashCommand extends AbstractCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,25 @@
|
|||||||
package com.seibel.distanthorizons.common.commands;
|
package com.seibel.distanthorizons.common.commands;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
#else
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
|
||||||
import static net.minecraft.commands.Commands.literal;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.minecraft.commands.Commands.literal;
|
||||||
|
|
||||||
public class DebugCommand extends AbstractCommand
|
public class DebugCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
private static String getDebugString()
|
|
||||||
{
|
|
||||||
List<String> lines = new ArrayList<>();
|
|
||||||
F3Screen.addStringToDisplay(lines);
|
|
||||||
return String.join("\n", lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
@Override
|
@Override
|
||||||
public LiteralArgumentBuilder<CommandSourceStack> buildCommand()
|
public LiteralArgumentBuilder<CommandSourceStack> buildCommand()
|
||||||
{
|
{
|
||||||
return literal("debug")
|
return literal("debug")
|
||||||
.executes(c -> {
|
.executes(c -> {
|
||||||
return this.sendSuccessResponse(c, getDebugString(), false);
|
List<String> lines = new ArrayList<>();
|
||||||
});
|
F3Screen.addStringToDisplay(lines);
|
||||||
|
return this.sendSuccessResponse(c, String.join("\n", lines), false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
public void execute(ICommandSender sender)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString(getDebugString()));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-112
@@ -1,36 +1,27 @@
|
|||||||
package com.seibel.distanthorizons.common.commands;
|
package com.seibel.distanthorizons.common.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
import com.seibel.distanthorizons.core.generation.PregenManager;
|
import com.seibel.distanthorizons.core.generation.PregenManager;
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D;
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D;
|
||||||
import com.seibel.distanthorizons.core.world.DhServerWorld;
|
import com.seibel.distanthorizons.core.world.DhServerWorld;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
#else
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
import net.minecraft.commands.arguments.DimensionArgument;
|
import net.minecraft.commands.arguments.DimensionArgument;
|
||||||
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
|
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
|
||||||
import net.minecraft.server.level.ColumnPos;
|
import net.minecraft.server.level.ColumnPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
|
||||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
|
||||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
|
||||||
import static net.minecraft.commands.Commands.argument;
|
|
||||||
import static net.minecraft.commands.Commands.literal;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
||||||
|
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||||
|
import static net.minecraft.commands.Commands.argument;
|
||||||
|
import static net.minecraft.commands.Commands.literal;
|
||||||
|
|
||||||
public class PregenCommand extends AbstractCommand
|
public class PregenCommand extends AbstractCommand
|
||||||
{
|
{
|
||||||
@@ -40,101 +31,6 @@ public class PregenCommand extends AbstractCommand
|
|||||||
return world.getPregenManager();
|
return world.getPregenManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length < 2)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Usage: /dh pregen <status|start|stop>"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args[1])
|
|
||||||
{
|
|
||||||
case "status":
|
|
||||||
{
|
|
||||||
String statusString = this.getPregenManager().getStatusString();
|
|
||||||
sender.sendMessage(new TextComponentString(
|
|
||||||
statusString != null ? statusString : "Pregen is not running"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "start":
|
|
||||||
{
|
|
||||||
if (args.length < 5)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Usage: /dh pregen start <dimension> <x> <z> <chunkRadius>"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String dimensionName = args[2];
|
|
||||||
int x = Integer.parseInt(args[3]);
|
|
||||||
int z = Integer.parseInt(args[4]);
|
|
||||||
int chunkRadius = args.length >= 6 ? Integer.parseInt(args[5]) : 32;
|
|
||||||
|
|
||||||
// find the world by dimension name
|
|
||||||
WorldServer world = null;
|
|
||||||
for (WorldServer w : server.worlds)
|
|
||||||
{
|
|
||||||
if (w.provider.getDimensionType().getName().equals(dimensionName))
|
|
||||||
{
|
|
||||||
world = w;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world == null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Unknown dimension: " + dimensionName));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(new TextComponentString("Starting pregen. Progress will be in the server console."));
|
|
||||||
|
|
||||||
final ICommandSender finalSender = sender;
|
|
||||||
CompletableFuture<Void> future = this.getPregenManager().startPregen(
|
|
||||||
ServerLevelWrapper.getWrapper(world),
|
|
||||||
new DhBlockPos2D(x, z),
|
|
||||||
chunkRadius
|
|
||||||
);
|
|
||||||
|
|
||||||
future.whenComplete((result, throwable) -> {
|
|
||||||
if (throwable instanceof CancellationException)
|
|
||||||
{
|
|
||||||
finalSender.sendMessage(new TextComponentString("Pregen is cancelled"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (throwable != null)
|
|
||||||
{
|
|
||||||
finalSender.sendMessage(new TextComponentString("Pregen failed: " + throwable.getMessage()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
finalSender.sendMessage(new TextComponentString("Pregen is complete"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Invalid number format"));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "stop":
|
|
||||||
{
|
|
||||||
CompletableFuture<Void> runningPregen = this.getPregenManager().getRunningPregen();
|
|
||||||
if (runningPregen == null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(new TextComponentString("Pregen is not running"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
runningPregen.cancel(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
sender.sendMessage(new TextComponentString("Unknown subcommand: " + args[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
@Override
|
@Override
|
||||||
public LiteralArgumentBuilder<CommandSourceStack> buildCommand()
|
public LiteralArgumentBuilder<CommandSourceStack> buildCommand()
|
||||||
{
|
{
|
||||||
@@ -214,5 +110,5 @@ public class PregenCommand extends AbstractCommand
|
|||||||
runningPregen.cancel(true);
|
runningPregen.cancel(true);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-9
@@ -1,6 +1,5 @@
|
|||||||
package com.seibel.distanthorizons.common.commonMixins;
|
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.api.enums.config.EDhApiUpdateBranch;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
@@ -12,18 +11,16 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
|
|||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.gui.screens.TitleScreen;
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
#endif
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class DhUpdateScreenBase
|
public class DhUpdateScreenBase
|
||||||
{
|
{
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final Minecraft MC = Minecraft #if MC_VER <= MC_1_12_2 .getMinecraft() #else .getInstance() #endif;
|
private static final Minecraft MC = Minecraft.getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void tryShowUpdateScreenAndRunAutoUpdateStartup(Runnable runnable)
|
public static void tryShowUpdateScreenAndRunAutoUpdateStartup(Runnable runnable)
|
||||||
@@ -73,10 +70,16 @@ public class DhUpdateScreenBase
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MC.setScreen(new UpdateModScreen(
|
UpdateModScreen updateScreen = new UpdateModScreen(
|
||||||
new TitleScreen(false),
|
new TitleScreen(false),
|
||||||
versionId
|
versionId
|
||||||
));
|
);
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
MC.setScreen(updateScreen);
|
||||||
|
#else
|
||||||
|
MC.setScreenAndShow(updateScreen);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -89,4 +92,3 @@ public class DhUpdateScreenBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+4
-22
@@ -6,23 +6,15 @@ import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
|||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
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.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||||
#endif
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
public class MixinChunkMapCommon
|
public class MixinChunkMapCommon
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static void onChunkSave(WorldServer level, Chunk chunk)
|
|
||||||
#else
|
|
||||||
public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable<Boolean> ci)
|
public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable<Boolean> ci)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level);
|
IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level);
|
||||||
|
|
||||||
@@ -45,7 +37,7 @@ public class MixinChunkMapCommon
|
|||||||
|
|
||||||
|
|
||||||
// is this chunk being saved to disk?
|
// is this chunk being saved to disk?
|
||||||
boolean savingChunkToDisk = #if MC_VER <= MC_1_12_2 true #else ci.getReturnValue() #endif;
|
boolean savingChunkToDisk = ci.getReturnValue();
|
||||||
// true means a chunk was saved to disk
|
// true means a chunk was saved to disk
|
||||||
if (!savingChunkToDisk)
|
if (!savingChunkToDisk)
|
||||||
{
|
{
|
||||||
@@ -58,12 +50,7 @@ public class MixinChunkMapCommon
|
|||||||
|
|
||||||
// MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks)
|
// 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
|
// this logic should prevent that from happening
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_17_1
|
||||||
if (!chunk.isTerrainPopulated() || !chunk.isLightPopulated())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect())
|
if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -80,12 +67,7 @@ public class MixinChunkMapCommon
|
|||||||
// biome validation //
|
// biome validation //
|
||||||
|
|
||||||
// some chunks may be missing their biomes, which cause issues when attempting to save them
|
// some chunks may be missing their biomes, which cause issues when attempting to save them
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_17_1
|
||||||
if (chunk. getBiomeArray() == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
if (chunk.getBiomes() == null)
|
if (chunk.getBiomes() == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
package com.seibel.distanthorizons.common.commonMixins;
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.modAccessor.ImmersivePortalsAccessorCommon;
|
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.level.ChunkPos;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
public class MixinImmersivePortalsRenderStatesCommon
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void saveVolatileOriginals()
|
|
||||||
{
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
ImmersivePortalsAccessorCommon.originalLevel = mc.level;
|
|
||||||
|
|
||||||
if (mc.player == null) {
|
|
||||||
ImmersivePortalsAccessorCommon.originalBlockPos = null;
|
|
||||||
ImmersivePortalsAccessorCommon.originalChunkPos = null;
|
|
||||||
ImmersivePortalsAccessorCommon.originalCameraPos = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockPos pos = mc.player.blockPosition();
|
|
||||||
ImmersivePortalsAccessorCommon.originalBlockPos = new DhBlockPos(pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
#if MC_VER < MC_1_17_1
|
|
||||||
ChunkPos cPos = new ChunkPos(mc.player.blockPosition());
|
|
||||||
#else
|
|
||||||
ChunkPos cPos = mc.player.chunkPosition();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_11
|
|
||||||
ImmersivePortalsAccessorCommon.originalChunkPos = new DhChunkPos(cPos.x, cPos.z);
|
|
||||||
#else
|
|
||||||
ImmersivePortalsAccessorCommon.originalChunkPos = new DhChunkPos(cPos.x(), cPos.z());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
|
||||||
Vec3 cameraPos = mc.gameRenderer.getMainCamera().getPosition();
|
|
||||||
#else
|
|
||||||
Vec3 cameraPos = mc.gameRenderer.getMainCamera().position();
|
|
||||||
#endif
|
|
||||||
ImmersivePortalsAccessorCommon.originalCameraPos = new Vec3d(cameraPos.x(), cameraPos.y(), cameraPos.z());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
+19
-47
@@ -7,22 +7,21 @@ import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
|||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.init.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
#elif MC_VER < MC_1_17_1
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
#if MC_VER < MC_1_17_1
|
||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
import net.minecraft.client.renderer.FogRenderer;
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||||
@@ -52,55 +51,41 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.world.level.material.FogType;
|
import net.minecraft.world.level.material.FogType;
|
||||||
import net.minecraft.client.renderer.fog.FogRenderer;
|
|
||||||
import net.minecraft.client.renderer.fog.FogData;
|
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public class MixinVanillaFogCommon
|
public class MixinVanillaFogCommon
|
||||||
{
|
{
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static boolean cancelFog(int startCoords, Minecraft mc)
|
#if MC_VER < MC_1_21_6
|
||||||
#elif MC_VER < MC_1_21_6
|
|
||||||
public static boolean cancelFog(Camera camera, FogRenderer.FogMode fogMode)
|
public static boolean cancelFog(Camera camera, FogRenderer.FogMode fogMode)
|
||||||
#else
|
#else
|
||||||
public static boolean cancelFog()
|
public static boolean cancelFog()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
EntityPlayerSP entity = mc.player;
|
#if MC_VER < MC_1_21_6
|
||||||
#elif MC_VER < MC_1_21_6
|
|
||||||
Entity entity = camera.getEntity();
|
Entity entity = camera.getEntity();
|
||||||
#elif MC_VER <= MC_1_21_10
|
#elif MC_VER <= MC_1_21_10
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
Entity entity = camera.getEntity();
|
Entity entity = camera.getEntity();
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
Entity entity = camera.entity();
|
Entity entity = camera.entity();
|
||||||
|
#else
|
||||||
|
Camera camera = Minecraft.getInstance().gameRenderer.mainCamera();
|
||||||
|
Entity entity = camera.entity();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
boolean cameraNotInFluid = cameraNotInFluid(mc);
|
|
||||||
#else
|
|
||||||
boolean cameraNotInFluid = cameraNotInFluid(camera);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
boolean cameraNotInFluid = cameraNotInFluid(camera);
|
||||||
boolean isSpecialFog = entity.isPotionActive(MobEffects.BLINDNESS);
|
|
||||||
#else
|
|
||||||
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
boolean isSpecialFog = (entity instanceof LivingEntity) && ((LivingEntity) entity).hasEffect(MobEffects.BLINDNESS);
|
||||||
#endif
|
|
||||||
|
|
||||||
boolean cancelFog = !isSpecialFog;
|
boolean cancelFog = !isSpecialFog;
|
||||||
cancelFog = cancelFog && cameraNotInFluid;
|
cancelFog = cancelFog && cameraNotInFluid;
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_6
|
||||||
cancelFog = cancelFog && startCoords == 0; // 0 = terrain fog
|
|
||||||
#elif MC_VER < MC_1_21_6
|
|
||||||
cancelFog = cancelFog && (fogMode == FogRenderer.FogMode.FOG_TERRAIN);
|
cancelFog = cancelFog && (fogMode == FogRenderer.FogMode.FOG_TERRAIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -108,25 +93,12 @@ public class MixinVanillaFogCommon
|
|||||||
cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get();
|
cancelFog = cancelFog && !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IImmersivePortalsAccessor immersivePortals = ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class);
|
|
||||||
if (immersivePortals != null
|
|
||||||
&& immersivePortals.isRenderingPortal())
|
|
||||||
{
|
|
||||||
cancelFog = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cancelFog;
|
return cancelFog;
|
||||||
}
|
}
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static boolean cameraNotInFluid(Minecraft mc)
|
|
||||||
#else
|
|
||||||
private static boolean cameraNotInFluid(Camera camera)
|
private static boolean cameraNotInFluid(Camera camera)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
boolean cameraNotInFluid = mc.getRenderViewEntity() != null && !mc.world.getBlockState(mc.getRenderViewEntity().getPosition()).getMaterial().isLiquid();
|
|
||||||
#elif MC_VER < MC_1_17_1
|
|
||||||
FluidState fluidState = camera.getFluidInCamera();
|
FluidState fluidState = camera.getFluidInCamera();
|
||||||
boolean cameraNotInFluid = fluidState.isEmpty();
|
boolean cameraNotInFluid = fluidState.isEmpty();
|
||||||
#else
|
#else
|
||||||
|
|||||||
+2
-1
@@ -10,6 +10,7 @@ import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterCo
|
|||||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiTextureCreatedParam;
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiTextureCreatedParam;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
@@ -86,7 +87,7 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
|
|||||||
@Override
|
@Override
|
||||||
public void applyToMcTexture(RenderParams renderParams)
|
public void applyToMcTexture(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
GpuTexture mcColorTexture = Minecraft.getInstance().getMainRenderTarget().getColorTexture();
|
GpuTexture mcColorTexture = MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture();
|
||||||
this.applyRenderer.render(this.dhColorTextureWrapper.texture, this.dhDepthTextureWrapper.texture, mcColorTexture);
|
this.applyRenderer.render(this.dhColorTextureWrapper.texture, this.dhDepthTextureWrapper.texture, mcColorTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -40,6 +40,7 @@ import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
|||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
@@ -151,7 +152,7 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
// textures
|
// textures
|
||||||
this.dhFadeColorTextureWrapper.tryCreateOrResize();
|
this.dhFadeColorTextureWrapper.tryCreateOrResize();
|
||||||
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||||
|
|
||||||
this.dhFadeDepthTextureWrapper.tryCreateOrResize();
|
this.dhFadeDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
|
|||||||
+25
-14
@@ -24,18 +24,6 @@ public class BlazeDhFogRenderer {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
|
||||||
import com.mojang.blaze3d.platform.DestFactor;
|
|
||||||
import com.mojang.blaze3d.platform.SourceFactor;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||||
@@ -62,6 +50,24 @@ import java.nio.ByteOrder;
|
|||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
|
import com.mojang.blaze3d.buffers.Std140Builder;
|
||||||
|
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
||||||
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
import com.mojang.blaze3d.platform.DestFactor;
|
||||||
|
import com.mojang.blaze3d.platform.SourceFactor;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.platform.BlendFactor;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders fog onto the LODs.
|
* Renders fog onto the LODs.
|
||||||
*/
|
*/
|
||||||
@@ -109,11 +115,16 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
this.init = true;
|
this.init = true;
|
||||||
|
|
||||||
|
|
||||||
|
BlendFunction blendFunc;
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
blendFunc = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
#else
|
||||||
|
blendFunc = new BlendFunction(BlendFactor.SRC_ALPHA, BlendFactor.ONE_MINUS_SRC_ALPHA, BlendFactor.ONE, BlendFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
#endif
|
||||||
|
|
||||||
this.applyRenderer = new BlazeDhApplyRenderer(
|
this.applyRenderer = new BlazeDhApplyRenderer(
|
||||||
"fog_apply_to_dh",
|
"fog_apply_to_dh",
|
||||||
new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA),
|
blendFunc,
|
||||||
"apply/blaze/vert", "apply/blaze/frag"
|
"apply/blaze/vert", "apply/blaze/frag"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+28
-13
@@ -24,18 +24,6 @@ public class BlazeDhSsaoRenderer {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
|
||||||
import com.mojang.blaze3d.platform.DestFactor;
|
|
||||||
import com.mojang.blaze3d.platform.SourceFactor;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
@@ -56,6 +44,25 @@ import java.nio.ByteOrder;
|
|||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
|
import com.mojang.blaze3d.buffers.Std140Builder;
|
||||||
|
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
||||||
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
|
import com.mojang.blaze3d.platform.BlendFactor;
|
||||||
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
import com.mojang.blaze3d.platform.DestFactor;
|
||||||
|
import com.mojang.blaze3d.platform.SourceFactor;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.platform.BlendFactor;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Renders SSAO to the DH LODs. */
|
/** Renders SSAO to the DH LODs. */
|
||||||
public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
||||||
{
|
{
|
||||||
@@ -101,9 +108,17 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
this.init = true;
|
this.init = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BlendFunction blendFunc;
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
blendFunc = new BlendFunction(SourceFactor.ZERO, DestFactor.SRC_ALPHA, SourceFactor.ZERO, DestFactor.ONE);
|
||||||
|
#else
|
||||||
|
blendFunc = new BlendFunction(BlendFactor.ZERO, BlendFactor.SRC_ALPHA, BlendFactor.ZERO, BlendFactor.ONE);
|
||||||
|
#endif
|
||||||
|
|
||||||
this.applyRenderer = new BlazeDhApplyRenderer(
|
this.applyRenderer = new BlazeDhApplyRenderer(
|
||||||
"ssao_apply_to_dh",
|
"ssao_apply_to_dh",
|
||||||
new BlendFunction(SourceFactor.ZERO, DestFactor.SRC_ALPHA, SourceFactor.ZERO, DestFactor.ONE),
|
blendFunc,
|
||||||
"apply/blaze/vert", "ssao/blaze/apply",
|
"apply/blaze/vert", "ssao/blaze/apply",
|
||||||
/*uniforms*/ new String[] { "applyFragUniformBlock" }
|
/*uniforms*/ new String[] { "applyFragUniformBlock" }
|
||||||
);
|
);
|
||||||
|
|||||||
+5
-7
@@ -43,6 +43,7 @@ import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
|||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
@@ -164,8 +165,8 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
this.fadeColorTextureWrapper.tryCreateOrResize();
|
this.fadeColorTextureWrapper.tryCreateOrResize();
|
||||||
this.fadeDepthTextureWrapper.tryCreateOrResize();
|
this.fadeDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
this.mcDepthTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
|
this.mcDepthTextureWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
|
||||||
this.mcColorTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -198,11 +199,8 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
Mat4f inverseMcMvmProjMatrix = inverseMcModelViewProjectionMatrix;
|
Mat4f inverseMcMvmProjMatrix = inverseMcModelViewProjectionMatrix;
|
||||||
|
|
||||||
|
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(renderParams.mcProjectionMatrix);
|
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(renderParams.dhProjectionMatrix);
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(renderParams.mcModelViewMatrix);
|
inverseDhModelViewProjectionMatrix.multiply(renderParams.dhModelViewMatrix);
|
||||||
|
|
||||||
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.invert();
|
inverseDhModelViewProjectionMatrix.invert();
|
||||||
Mat4f inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
Mat4f inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -37,6 +37,7 @@ import com.mojang.blaze3d.vertex.VertexFormat;
|
|||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
@@ -164,8 +165,8 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
|||||||
{
|
{
|
||||||
this.tryInit();
|
this.tryInit();
|
||||||
|
|
||||||
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||||
this.mcDepthTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
|
this.mcDepthTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
|
||||||
|
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
|
|||||||
+16
-1
@@ -5,6 +5,7 @@ public class BlazeDhVertexFormatUtil {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
@@ -70,7 +71,7 @@ public class BlazeDhVertexFormatUtil
|
|||||||
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
||||||
|
|
||||||
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 3);
|
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 3);
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 2);
|
SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 2);
|
||||||
RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 4);
|
RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 4);
|
||||||
|
|
||||||
@@ -83,6 +84,20 @@ public class BlazeDhVertexFormatUtil
|
|||||||
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
||||||
|
|
||||||
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 3);
|
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 3);
|
||||||
|
#else
|
||||||
|
|
||||||
|
SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, GpuFormat.RG32_FLOAT); // 2 floats
|
||||||
|
RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, GpuFormat.RGBA32_FLOAT); // 4 floats
|
||||||
|
|
||||||
|
SHORT_XYZ_POS = VertexFormatElement.register(/*id*/24, /*index*/0, GpuFormat.RGB16_UINT); // 3 ushorts
|
||||||
|
BYTE_PAD = VertexFormatElement.register(/*id*/25, /*index*/0, GpuFormat.R8_UINT); // 1 byte
|
||||||
|
|
||||||
|
META = VertexFormatElement.register(/*id*/26, /*index*/0, GpuFormat.R16_UINT); // 1 ushort
|
||||||
|
RGBA_UBYTE_COLOR = VertexFormatElement.register(/*id*/27, /*index*/0, GpuFormat.RGBA8_UNORM); // 4 ubytes
|
||||||
|
IRIS_MATERIAL = VertexFormatElement.register(/*id*/28, /*index*/0, GpuFormat.R8_UINT); // 1 byte
|
||||||
|
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, GpuFormat.R8_UINT); // 1 byte
|
||||||
|
|
||||||
|
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, GpuFormat.RGB32_FLOAT); // 3 floats
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
+40
-4
@@ -6,8 +6,8 @@ public class RenderPipelineBuilderWrapper {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.*;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
import com.mojang.blaze3d.platform.PolygonMode;
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
import com.mojang.blaze3d.shaders.UniformType;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
@@ -16,13 +16,12 @@ import net.minecraft.resources.Identifier;
|
|||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
import com.mojang.blaze3d.platform.DepthTestFunction;
|
import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||||
#else
|
#else
|
||||||
import com.mojang.blaze3d.pipeline.ColorTargetState;
|
|
||||||
import com.mojang.blaze3d.pipeline.DepthStencilState;
|
|
||||||
import com.mojang.blaze3d.platform.CompareOp;
|
import com.mojang.blaze3d.platform.CompareOp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class RenderPipelineBuilderWrapper
|
public class RenderPipelineBuilderWrapper
|
||||||
@@ -130,15 +129,27 @@ public class RenderPipelineBuilderWrapper
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final ArrayList<String> samplerNames = new ArrayList<>();
|
||||||
public RenderPipelineBuilderWrapper withSampler(String name) throws IllegalArgumentException
|
public RenderPipelineBuilderWrapper withSampler(String name) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
this.blazePipelineBuilder.withSampler(name);
|
this.blazePipelineBuilder.withSampler(name);
|
||||||
|
#else
|
||||||
|
samplerNames.add(name);
|
||||||
|
#endif
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final ArrayList<String> uniformBufferNames = new ArrayList<>();
|
||||||
public RenderPipelineBuilderWrapper withUniformBuffer(String name) throws IllegalArgumentException
|
public RenderPipelineBuilderWrapper withUniformBuffer(String name) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
this.blazePipelineBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
|
this.blazePipelineBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
|
||||||
|
#else
|
||||||
|
uniformBufferNames.add(name);
|
||||||
|
#endif
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,6 +293,31 @@ public class RenderPipelineBuilderWrapper
|
|||||||
this.blazePipelineBuilder.withVertexFormat(vertexFormat, blazeVertexMode);
|
this.blazePipelineBuilder.withVertexFormat(vertexFormat, blazeVertexMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// uniform buffers
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
// handled before this point
|
||||||
|
#else
|
||||||
|
|
||||||
|
BindGroupLayout.Builder bindGroupBuilder = BindGroupLayout.builder();
|
||||||
|
|
||||||
|
for (String name : this.samplerNames)
|
||||||
|
{
|
||||||
|
bindGroupBuilder.withSampler(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String name : this.uniformBufferNames)
|
||||||
|
{
|
||||||
|
bindGroupBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
|
||||||
|
}
|
||||||
|
|
||||||
|
BindGroupLayout bindGroup = bindGroupBuilder.build();
|
||||||
|
this.blazePipelineBuilder.withBindGroupLayout(bindGroup);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return this.blazePipelineBuilder.build();
|
return this.blazePipelineBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+39
-10
@@ -5,11 +5,6 @@ public class BlazeTextureWrapper {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.textures.*;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -18,6 +13,17 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRen
|
|||||||
|
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.textures.*;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
|
#endif
|
||||||
|
|
||||||
public class BlazeTextureWrapper
|
public class BlazeTextureWrapper
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
@@ -29,7 +35,11 @@ public class BlazeTextureWrapper
|
|||||||
|
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
public final TextureFormat textureFormat;
|
public final TextureFormat textureFormat;
|
||||||
|
#else
|
||||||
|
public final GpuFormat textureFormat;
|
||||||
|
#endif
|
||||||
|
|
||||||
public GpuTexture texture = null;
|
public GpuTexture texture = null;
|
||||||
public GpuTextureView textureView = null;
|
public GpuTextureView textureView = null;
|
||||||
@@ -45,10 +55,27 @@ public class BlazeTextureWrapper
|
|||||||
//==============//
|
//==============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
public static BlazeTextureWrapper createDepth(String name) { return new BlazeTextureWrapper(name, TextureFormat.DEPTH32); }
|
public static BlazeTextureWrapper createDepth(String name)
|
||||||
public static BlazeTextureWrapper createColor(String name) { return new BlazeTextureWrapper(name, TextureFormat.RGBA8); }
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
return new BlazeTextureWrapper(name, TextureFormat.DEPTH32);
|
||||||
|
#else
|
||||||
|
return new BlazeTextureWrapper(name, GpuFormat.D32_FLOAT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
public static BlazeTextureWrapper createColor(String name)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
return new BlazeTextureWrapper(name, TextureFormat.RGBA8);
|
||||||
|
#else
|
||||||
|
return new BlazeTextureWrapper(name, GpuFormat.RGBA8_UNORM);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private BlazeTextureWrapper(String name, TextureFormat textureFormat)
|
private BlazeTextureWrapper(
|
||||||
|
String name,
|
||||||
|
#if MC_VER <= MC_26_1_2 TextureFormat #else GpuFormat #endif textureFormat
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.textureFormat = textureFormat;
|
this.textureFormat = textureFormat;
|
||||||
@@ -116,11 +143,13 @@ public class BlazeTextureWrapper
|
|||||||
| GpuTexture.USAGE_TEXTURE_BINDING
|
| GpuTexture.USAGE_TEXTURE_BINDING
|
||||||
| GpuTexture.USAGE_COPY_SRC
|
| GpuTexture.USAGE_COPY_SRC
|
||||||
| GpuTexture.USAGE_RENDER_ATTACHMENT;
|
| GpuTexture.USAGE_RENDER_ATTACHMENT;
|
||||||
this.texture = GPU_DEVICE.createTexture(this.name,
|
|
||||||
|
this.texture = GPU_DEVICE.createTexture(
|
||||||
|
this.name,
|
||||||
usage,
|
usage,
|
||||||
this.textureFormat,
|
this.textureFormat,
|
||||||
viewWidth, viewHeight,
|
viewWidth, viewHeight,
|
||||||
/*depthOrLayers*/ 1, /*mipLevels*/ 1
|
/*depthOrLayers*/ 1, /*mipLevels*/ 1
|
||||||
);
|
);
|
||||||
this.textureView = GPU_DEVICE.createTextureView(this.texture);
|
this.textureView = GPU_DEVICE.createTextureView(this.texture);
|
||||||
|
|
||||||
|
|||||||
+2
@@ -126,6 +126,8 @@ public class GLProxy
|
|||||||
|
|
||||||
private GLProxy() throws IllegalStateException
|
private GLProxy() throws IllegalStateException
|
||||||
{
|
{
|
||||||
|
// TODO vulkan complain if created when MC is running on vulkan
|
||||||
|
|
||||||
// this must be created on minecraft's render context to work correctly
|
// this must be created on minecraft's render context to work correctly
|
||||||
if (GLFW.glfwGetCurrentContext() == 0L)
|
if (GLFW.glfwGetCurrentContext() == 0L)
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-18
@@ -97,9 +97,7 @@ public class GLState implements AutoCloseable
|
|||||||
{
|
{
|
||||||
this.frameBufferTexture0 = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
this.frameBufferTexture0 = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||||
this.frameBufferTexture1 = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
this.frameBufferTexture1 = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||||
|
this.frameBufferDepthTexture = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
|
||||||
int depthType = GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
|
|
||||||
this.frameBufferDepthTexture = (depthType == GL32.GL_TEXTURE) ? GL32.glGetFramebufferAttachmentParameteri(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) : 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -181,21 +179,9 @@ public class GLState implements AutoCloseable
|
|||||||
// attempting to set textures on the default frame buffer (ID 0) will throw errors
|
// attempting to set textures on the default frame buffer (ID 0) will throw errors
|
||||||
if (frameBufferSet)
|
if (frameBufferSet)
|
||||||
{
|
{
|
||||||
if (GL32.glIsTexture(this.frameBufferTexture0))
|
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.frameBufferTexture0, 0);
|
||||||
{
|
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_TEXTURE_2D, this.frameBufferTexture1, 0);
|
||||||
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.frameBufferTexture0, 0);
|
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_TEXTURE_2D, this.frameBufferDepthTexture, 0);
|
||||||
}
|
|
||||||
|
|
||||||
if (this.frameBufferTexture1 != 0 && GL32.glIsTexture(this.frameBufferTexture1))
|
|
||||||
{
|
|
||||||
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_TEXTURE_2D, this.frameBufferTexture1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GL32.glIsTexture(this.frameBufferDepthTexture))
|
|
||||||
{
|
|
||||||
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_TEXTURE_2D, this.frameBufferDepthTexture, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0);
|
GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0);
|
||||||
|
|||||||
@@ -22,34 +22,23 @@ package com.seibel.distanthorizons.common.util;
|
|||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
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.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
#endif
|
|
||||||
public class ProxyUtil
|
public class ProxyUtil
|
||||||
{
|
{
|
||||||
|
|
||||||
public static ILevelWrapper getLevelWrapper(
|
public static ILevelWrapper getLevelWrapper(LevelAccessor level)
|
||||||
#if MC_VER <= MC_1_12_2 World #else LevelAccessor #endif level
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ILevelWrapper levelWrapper;
|
ILevelWrapper levelWrapper;
|
||||||
if (level instanceof #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif)
|
if (level instanceof ServerLevel)
|
||||||
{
|
{
|
||||||
levelWrapper = ServerLevelWrapper.getWrapper(
|
levelWrapper = ServerLevelWrapper.getWrapper((ServerLevel) level);
|
||||||
#if MC_VER <= MC_1_12_2 (WorldServer) #else (ServerLevel) #endif level
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
levelWrapper = ClientLevelWrapper.getWrapper(
|
levelWrapper = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||||
#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif level
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return levelWrapper;
|
return levelWrapper;
|
||||||
|
|||||||
+17
-101
@@ -26,15 +26,9 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
|||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
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.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts to and from Minecraft objects (Ex: Matrix4f)
|
* This class converts to and from Minecraft objects (Ex: Matrix4f)
|
||||||
@@ -45,17 +39,15 @@ import net.minecraft.world.level.ChunkPos;
|
|||||||
*/
|
*/
|
||||||
public class McObjectConverter
|
public class McObjectConverter
|
||||||
{
|
{
|
||||||
|
private static int bufferIndex(int x, int y)
|
||||||
|
{
|
||||||
|
return y * 4 + x;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========//
|
|
||||||
// matrix //
|
|
||||||
//========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
/** 4x4 float matrix converter */
|
/** 4x4 float matrix converter */
|
||||||
public static Mat4f Convert(
|
public static Mat4f Convert(
|
||||||
#if MC_VER <= MC_1_12_2 org.joml.Matrix4f
|
#if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
|
||||||
#elif MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
|
|
||||||
#elif MC_VER < MC_1_21_6 org.joml.Matrix4f
|
#elif MC_VER < MC_1_21_6 org.joml.Matrix4f
|
||||||
#else org.joml.Matrix4fc
|
#else org.joml.Matrix4fc
|
||||||
#endif
|
#endif
|
||||||
@@ -64,24 +56,21 @@ public class McObjectConverter
|
|||||||
FloatBuffer buffer = FloatBuffer.allocate(16);
|
FloatBuffer buffer = FloatBuffer.allocate(16);
|
||||||
storeMatrix(mcMatrix, buffer);
|
storeMatrix(mcMatrix, buffer);
|
||||||
Mat4f matrix = new Mat4f(buffer);
|
Mat4f matrix = new Mat4f(buffer);
|
||||||
#if MC_VER > MC_1_12_2 && MC_VER < MC_1_19_4
|
#if MC_VER < MC_1_19_4
|
||||||
matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it
|
matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it
|
||||||
#endif
|
#endif
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
/** Taken from Minecraft's com.mojang.math.Matrix4f class from 1.18.2 */
|
/** Taken from Minecraft's com.mojang.math.Matrix4f class from 1.18.2 */
|
||||||
private static void storeMatrix(
|
private static void storeMatrix(
|
||||||
#if MC_VER <= MC_1_12_2 org.joml.Matrix4f
|
#if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
|
||||||
#elif MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
|
|
||||||
#elif MC_VER < MC_1_21_6 org.joml.Matrix4f
|
#elif MC_VER < MC_1_21_6 org.joml.Matrix4f
|
||||||
#else org.joml.Matrix4fc
|
#else org.joml.Matrix4fc
|
||||||
#endif
|
#endif
|
||||||
matrix,
|
matrix,
|
||||||
FloatBuffer buffer)
|
FloatBuffer buffer)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_4
|
||||||
matrix.get(buffer);
|
|
||||||
#elif MC_VER < MC_1_19_4
|
|
||||||
matrix.store(buffer);
|
matrix.store(buffer);
|
||||||
#else
|
#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
|
// 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
|
||||||
@@ -103,85 +92,37 @@ public class McObjectConverter
|
|||||||
buffer.put(bufferIndex(3, 3), matrix.m33());
|
buffer.put(bufferIndex(3, 3), matrix.m33());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
private static int bufferIndex(int x, int y) { return y * 4 + x; }
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
static final Direction[] directions;
|
||||||
//===========//
|
static final EDhDirection[] lodDirections;
|
||||||
// direction //
|
|
||||||
//===========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final EnumFacing[] mcDirections;
|
|
||||||
#else
|
|
||||||
private static final Direction[] mcDirections;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private static final EDhDirection[] dhDirections;
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
EDhDirection[] lodDirs = EDhDirection.values();
|
EDhDirection[] lodDirs = EDhDirection.values();
|
||||||
|
directions = new Direction[lodDirs.length];
|
||||||
#if MC_VER <= MC_1_12_2
|
lodDirections = new EDhDirection[lodDirs.length];
|
||||||
mcDirections = new EnumFacing[lodDirs.length];
|
|
||||||
#else
|
|
||||||
mcDirections = new Direction[lodDirs.length];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
dhDirections = new EDhDirection[lodDirs.length];
|
|
||||||
for (EDhDirection lodDir : lodDirs)
|
for (EDhDirection lodDir : lodDirs)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
EnumFacing dir;
|
|
||||||
#else
|
|
||||||
Direction dir;
|
Direction dir;
|
||||||
#endif
|
|
||||||
switch (lodDir.name().toUpperCase())
|
switch (lodDir.name().toUpperCase())
|
||||||
{
|
{
|
||||||
case "DOWN":
|
case "DOWN":
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
dir = EnumFacing.DOWN;
|
|
||||||
#else
|
|
||||||
dir = Direction.DOWN;
|
dir = Direction.DOWN;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case "UP":
|
case "UP":
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
dir = EnumFacing.UP;
|
|
||||||
#else
|
|
||||||
dir = Direction.UP;
|
dir = Direction.UP;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case "NORTH":
|
case "NORTH":
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
dir = EnumFacing.NORTH;
|
|
||||||
#else
|
|
||||||
dir = Direction.NORTH;
|
dir = Direction.NORTH;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case "SOUTH":
|
case "SOUTH":
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
dir = EnumFacing.SOUTH;
|
|
||||||
#else
|
|
||||||
dir = Direction.SOUTH;
|
dir = Direction.SOUTH;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case "WEST":
|
case "WEST":
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
dir = EnumFacing.WEST;
|
|
||||||
#else
|
|
||||||
dir = Direction.WEST;
|
dir = Direction.WEST;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case "EAST":
|
case "EAST":
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
dir = EnumFacing.EAST;
|
|
||||||
#else
|
|
||||||
dir = Direction.EAST;
|
dir = Direction.EAST;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dir = null;
|
dir = null;
|
||||||
@@ -190,37 +131,13 @@ public class McObjectConverter
|
|||||||
|
|
||||||
if (dir == null)
|
if (dir == null)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Invalid direction on init mapping: [" + lodDir + "].");
|
throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir);
|
||||||
}
|
}
|
||||||
mcDirections[lodDir.ordinal()] = dir;
|
directions[lodDir.ordinal()] = dir;
|
||||||
dhDirections[dir.ordinal()] = lodDir;
|
lodDirections[dir.ordinal()] = lodDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static EnumFacing Convert(EDhDirection lodDirection)
|
|
||||||
#else
|
|
||||||
public static Direction Convert(EDhDirection lodDirection)
|
|
||||||
#endif
|
|
||||||
{ return mcDirections[lodDirection.ordinal()]; }
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static EDhDirection Convert(EnumFacing direction)
|
|
||||||
#else
|
|
||||||
public static EDhDirection Convert(Direction direction)
|
|
||||||
#endif
|
|
||||||
{ return dhDirections[direction.ordinal()]; }
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================//
|
|
||||||
// position objects //
|
|
||||||
//==================//
|
|
||||||
//region
|
|
||||||
|
|
||||||
public static BlockPos Convert(DhBlockPos wrappedPos) { return new BlockPos(wrappedPos.getX(), wrappedPos.getY(), wrappedPos.getZ()); }
|
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 ChunkPos Convert(DhChunkPos wrappedPos) { return new ChunkPos(wrappedPos.getX(), wrappedPos.getZ()); }
|
||||||
@@ -233,8 +150,7 @@ public class McObjectConverter
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
public static Direction Convert(EDhDirection lodDirection) { return directions[lodDirection.ordinal()]; }
|
||||||
|
public static EDhDirection Convert(Direction direction) { return lodDirections[direction.ordinal()]; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -51,10 +51,7 @@ public class VersionConstants implements IVersionConstants
|
|||||||
// it can't load client classes when running as a dedicated server,
|
// it can't load client classes when running as a dedicated server,
|
||||||
// which was how we were dynamically accessing the MC version string
|
// which was how we were dynamically accessing the MC version string
|
||||||
|
|
||||||
#if MC_VER == MC_1_12_2
|
#if MC_VER == MC_1_16_5
|
||||||
return "1.12.2";
|
|
||||||
|
|
||||||
#elif MC_VER == MC_1_16_5
|
|
||||||
return "1.16.5";
|
return "1.16.5";
|
||||||
|
|
||||||
#elif MC_VER == MC_1_17_1
|
#elif MC_VER == MC_1_17_1
|
||||||
@@ -98,6 +95,8 @@ public class VersionConstants implements IVersionConstants
|
|||||||
return "1.21.11";
|
return "1.21.11";
|
||||||
#elif MC_VER == MC_26_1_2
|
#elif MC_VER == MC_26_1_2
|
||||||
return "26.1.2";
|
return "26.1.2";
|
||||||
|
#elif MC_VER == MC_26_2_0
|
||||||
|
return "26.2.0";
|
||||||
#else
|
#else
|
||||||
ERROR MC version constant missing
|
ERROR MC version constant missing
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+45
-137
@@ -46,30 +46,17 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
#if MC_VER > MC_1_17_1
|
#if MC_VER > MC_1_17_1
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
import net.minecraft.world.chunk.Chunk;
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelReader;
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This handles creating abstract wrapper objects.
|
* This handles creating abstract wrapper objects.
|
||||||
@@ -185,8 +172,7 @@ public class WrapperFactory implements IWrapperFactory
|
|||||||
*/
|
*/
|
||||||
public IChunkWrapper createChunkWrapper(Object[] objectArray) throws ClassCastException
|
public IChunkWrapper createChunkWrapper(Object[] objectArray) throws ClassCastException
|
||||||
{
|
{
|
||||||
if (objectArray.length == 1
|
if (objectArray.length == 1 && objectArray[0] instanceof IChunkWrapper)
|
||||||
&& objectArray[0] instanceof IChunkWrapper)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -200,102 +186,41 @@ public class WrapperFactory implements IWrapperFactory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (objectArray.length != 2)
|
//#if MC_VER <= MC_1_XX_X
|
||||||
|
else if (objectArray.length == 2)
|
||||||
{
|
{
|
||||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
// correct number of parameters from the API
|
||||||
}
|
|
||||||
|
// chunk
|
||||||
|
if (!(objectArray[0] instanceof ChunkAccess))
|
||||||
// correct number of parameters from the API
|
{
|
||||||
|
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||||
//=======//
|
}
|
||||||
// chunk //
|
ChunkAccess chunk = (ChunkAccess) objectArray[0];
|
||||||
//=======//
|
|
||||||
//region
|
// level / light source
|
||||||
|
if (!(objectArray[1] instanceof Level))
|
||||||
boolean chunkClassCorrect;
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||||
chunkClassCorrect = (objectArray[0] instanceof Chunk);
|
}
|
||||||
#else
|
// the level is needed for the DH level wrapper...
|
||||||
chunkClassCorrect = (objectArray[0] instanceof ChunkAccess);
|
Level level = (Level) objectArray[1];
|
||||||
#endif
|
|
||||||
if (!chunkClassCorrect)
|
|
||||||
{
|
// level wrapper
|
||||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
ILevelWrapper levelWrapper = level.isClientSide()
|
||||||
}
|
? ClientLevelWrapper.getWrapper((ClientLevel)level)
|
||||||
|
: ServerLevelWrapper.getWrapper((ServerLevel)level);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Chunk chunk = (Chunk) objectArray[0];
|
|
||||||
#else
|
return new ChunkWrapper(chunk, levelWrapper);
|
||||||
ChunkAccess chunk = (ChunkAccess) objectArray[0];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=======//
|
|
||||||
// level //
|
|
||||||
//=======//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean levelClassCorrect;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
levelClassCorrect = (objectArray[1] instanceof World);
|
|
||||||
#else
|
|
||||||
levelClassCorrect = (objectArray[1] instanceof Level);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!levelClassCorrect)
|
|
||||||
{
|
|
||||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
World level = (World) objectArray[1];
|
|
||||||
#else
|
|
||||||
Level level = (Level) objectArray[1];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===============//
|
|
||||||
// level wrapper //
|
|
||||||
//===============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isClientSide;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isClientSide = !level.isRemote;
|
|
||||||
#else
|
|
||||||
isClientSide = level.isClientSide();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ILevelWrapper levelWrapper;
|
|
||||||
if (isClientSide)
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
levelWrapper = ClientLevelWrapper.getWrapper((WorldClient)level);
|
|
||||||
#else
|
|
||||||
levelWrapper = ClientLevelWrapper.getWrapper((ClientLevel)level);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
// incorrect number of parameters from the API
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||||
levelWrapper = ServerLevelWrapper.getWrapper((WorldServer)level);
|
|
||||||
#else
|
|
||||||
levelWrapper = ServerLevelWrapper.getWrapper((ServerLevel)level);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new ChunkWrapper(chunk, levelWrapper);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Note: when this is updated for different MC versions,
|
* Note: when this is updated for different MC versions,
|
||||||
@@ -305,19 +230,13 @@ public class WrapperFactory implements IWrapperFactory
|
|||||||
{
|
{
|
||||||
String[] expectedClassNames;
|
String[] expectedClassNames;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
//#if MC_VER <= MC_1_XX_X
|
||||||
expectedClassNames = new String[]
|
expectedClassNames = new String[]
|
||||||
{
|
{
|
||||||
Chunk.class.getName(),
|
ChunkAccess.class.getName(),
|
||||||
"[WorldClient] or [WorldServer]" // Classes are not referenced by names to avoid exception when one of them is missing
|
"[ServerLevel] or [ClientLevel]" // Classes are not referenced by names to avoid exception when one of them is missing
|
||||||
};
|
};
|
||||||
#else
|
//#endif
|
||||||
expectedClassNames = new String[]
|
|
||||||
{
|
|
||||||
ChunkAccess.class.getName(),
|
|
||||||
"[ServerLevel] or [ClientLevel]" // Classes are not referenced by names to avoid exception when one of them is missing
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return createWrapperErrorMessage("Chunk wrapper", expectedClassNames, objectArray);
|
return createWrapperErrorMessage("Chunk wrapper", expectedClassNames, objectArray);
|
||||||
}
|
}
|
||||||
@@ -403,29 +322,19 @@ public class WrapperFactory implements IWrapperFactory
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#if MC_VER <= MC_1_XX_X
|
||||||
if (objectArray.length != 1)
|
if (objectArray.length != 1)
|
||||||
{
|
{
|
||||||
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
|
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
|
||||||
}
|
}
|
||||||
|
if (!(objectArray[0] instanceof BlockState))
|
||||||
boolean blockClassCorrect;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
blockClassCorrect = (objectArray[0] instanceof IBlockState);
|
|
||||||
#else
|
|
||||||
blockClassCorrect = (objectArray[0] instanceof BlockState);
|
|
||||||
#endif
|
|
||||||
if (!blockClassCorrect)
|
|
||||||
{
|
{
|
||||||
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
|
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
IBlockState blockState = (IBlockState) objectArray[0];
|
|
||||||
return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper);
|
|
||||||
#else
|
|
||||||
BlockState blockState = (BlockState) objectArray[0];
|
BlockState blockState = (BlockState) objectArray[0];
|
||||||
return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper);
|
return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper);
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Note: when this is updated for different MC versions,
|
* Note: when this is updated for different MC versions,
|
||||||
@@ -435,9 +344,7 @@ public class WrapperFactory implements IWrapperFactory
|
|||||||
{
|
{
|
||||||
String[] expectedClassNames;
|
String[] expectedClassNames;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
||||||
expectedClassNames = new String[] { IBlockState.class.getName() };
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
expectedClassNames = new String[] { Biome.class.getName() };
|
expectedClassNames = new String[] { Biome.class.getName() };
|
||||||
#else
|
#else
|
||||||
expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" };
|
expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" };
|
||||||
@@ -450,6 +357,7 @@ public class WrapperFactory implements IWrapperFactory
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// helper methods //
|
// helper methods //
|
||||||
//================//
|
//================//
|
||||||
@@ -459,8 +367,8 @@ public class WrapperFactory implements IWrapperFactory
|
|||||||
{
|
{
|
||||||
// error header
|
// error header
|
||||||
StringBuilder message = new StringBuilder(
|
StringBuilder message = new StringBuilder(
|
||||||
wrapperName + " creation failed. \n" +
|
wrapperName + " creation failed. \n" +
|
||||||
"Expected object array parameters: \n");
|
"Expected object array parameters: \n");
|
||||||
|
|
||||||
|
|
||||||
// expected parameters
|
// expected parameters
|
||||||
|
|||||||
+7
-10
@@ -1,5 +1,5 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.block;
|
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.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.BlockBiomeWrapperPair;
|
import com.seibel.distanthorizons.core.dataObjects.BlockBiomeWrapperPair;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
@@ -11,14 +11,10 @@ import com.seibel.distanthorizons.core.util.FullDataPointUtil;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import net.minecraft.client.Minecraft;
|
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.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.ColorResolver;
|
import net.minecraft.world.level.ColorResolver;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -49,6 +45,8 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static final ConcurrentHashMap<BlockBiomeWrapperPair, Integer> COLOR_BY_BLOCK_BIOME_PAIR = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<BlockBiomeWrapperPair, Integer> COLOR_BY_BLOCK_BIOME_PAIR = new ConcurrentHashMap<>();
|
||||||
|
/** returned if the color cache is incomplete */
|
||||||
|
public static final int INVALID_COLOR = -1;
|
||||||
|
|
||||||
|
|
||||||
protected BiomeWrapper biomeWrapper;
|
protected BiomeWrapper biomeWrapper;
|
||||||
@@ -100,7 +98,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
* Can be called by DH directly, skipping some of MC's logic
|
* Can be called by DH directly, skipping some of MC's logic
|
||||||
* to speed up tint getting slightly.
|
* to speed up tint getting slightly.
|
||||||
*
|
*
|
||||||
* @return {@link ClientBlockStateColorCache#INVALID_COLOR} if any of the biomes needed for this position
|
* @return {@link AbstractDhTintGetter#INVALID_COLOR} if any of the biomes needed for this position
|
||||||
* were not cached. In that case calling {@link AbstractDhTintGetter#getBlockTint(BlockPos, ColorResolver)}
|
* were not cached. In that case calling {@link AbstractDhTintGetter#getBlockTint(BlockPos, ColorResolver)}
|
||||||
* will need to be called by MC's ColorResolver so we can
|
* will need to be called by MC's ColorResolver so we can
|
||||||
* populate the color cache.
|
* populate the color cache.
|
||||||
@@ -161,9 +159,9 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
int id = FullDataPointUtil.getId(dataPoint);
|
int id = FullDataPointUtil.getId(dataPoint);
|
||||||
BiomeWrapper biomeWrapper = (BiomeWrapper) this.fullDataSource.mapping.getBiomeWrapper(id);
|
BiomeWrapper biomeWrapper = (BiomeWrapper) this.fullDataSource.mapping.getBiomeWrapper(id);
|
||||||
int color = this.tryGetClientBiomeColor(colorResolver, biomeWrapper);
|
int color = this.tryGetClientBiomeColor(colorResolver, biomeWrapper);
|
||||||
if (color == ClientBlockStateColorCache.INVALID_COLOR)
|
if (color == INVALID_COLOR)
|
||||||
{
|
{
|
||||||
return ClientBlockStateColorCache.INVALID_COLOR;
|
return INVALID_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -212,7 +210,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
// no color resolver is present,
|
// no color resolver is present,
|
||||||
// the cache needs to be populated before
|
// the cache needs to be populated before
|
||||||
// we can use the fast path
|
// we can use the fast path
|
||||||
return ClientBlockStateColorCache.INVALID_COLOR;
|
return INVALID_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -365,4 +363,3 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+11
-64
@@ -28,15 +28,12 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
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.logging.DhLogger;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
|
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
@@ -48,21 +45,14 @@ import net.minecraft.core.Holder;
|
|||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.core.component.DataComponentMap;
|
import net.minecraft.core.component.DataComponentMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
#else
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_18_2
|
#if MC_VER >= MC_1_18_2
|
||||||
import net.minecraft.world.level.biome.Biomes;
|
import net.minecraft.world.level.biome.Biomes;
|
||||||
@@ -118,13 +108,8 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
//==============//
|
//==============//
|
||||||
// constructors //
|
// constructors //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER < MC_1_18_2
|
public static BiomeWrapper getBiomeWrapper(#if MC_VER < MC_1_18_2 Biome #else Holder<Biome> #endif biome, ILevelWrapper levelWrapper)
|
||||||
public static BiomeWrapper getBiomeWrapper(Biome biome, ILevelWrapper levelWrapper)
|
|
||||||
#else
|
|
||||||
public static BiomeWrapper getBiomeWrapper(Holder<Biome> biome, ILevelWrapper levelWrapper)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (biome == null)
|
if (biome == null)
|
||||||
{
|
{
|
||||||
@@ -144,12 +129,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
return newWrapper;
|
return newWrapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private BiomeWrapper(#if MC_VER < MC_1_18_2 Biome #else Holder<Biome> #endif biome, ILevelWrapper levelWrapper)
|
||||||
#if MC_VER < MC_1_18_2
|
|
||||||
private BiomeWrapper(Biome biome, ILevelWrapper levelWrapper)
|
|
||||||
#else
|
|
||||||
private BiomeWrapper(Holder<Biome> biome, ILevelWrapper levelWrapper)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
this.biome = biome;
|
this.biome = biome;
|
||||||
this.serialString = this.serialize(levelWrapper);
|
this.serialString = this.serialize(levelWrapper);
|
||||||
@@ -158,14 +138,11 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
//LOGGER.trace("Created BiomeWrapper ["+this.serialString+"] for ["+biome+"]");
|
//LOGGER.trace("Created BiomeWrapper ["+this.serialString+"] for ["+biome+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=========//
|
//=========//
|
||||||
// methods //
|
// methods //
|
||||||
//=========//
|
//=========//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
@@ -211,14 +188,11 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
@Override
|
@Override
|
||||||
public String toString() { return this.getSerialString(); }
|
public String toString() { return this.getSerialString(); }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=======================//
|
//=======================//
|
||||||
// serialization methods //
|
// serialization methods //
|
||||||
//=======================//
|
//=======================//
|
||||||
//region
|
|
||||||
|
|
||||||
public String serialize(ILevelWrapper levelWrapper)
|
public String serialize(ILevelWrapper levelWrapper)
|
||||||
{
|
{
|
||||||
@@ -245,10 +219,8 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
|
|
||||||
// generate the serial string //
|
// generate the serial string //
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
Level level = (Level)levelWrapper.getWrappedMcObject();
|
Level level = (Level)levelWrapper.getWrappedMcObject();
|
||||||
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
ResourceLocation resourceLocation;
|
ResourceLocation resourceLocation;
|
||||||
@@ -256,9 +228,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
Identifier resourceLocation;
|
Identifier resourceLocation;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_17_1
|
||||||
resourceLocation = biome.getRegistryName();
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome);
|
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome);
|
||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value());
|
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value());
|
||||||
@@ -323,16 +293,11 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
Level level = (Level) levelWrapper.getWrappedMcObject();
|
Level level = (Level) levelWrapper.getWrappedMcObject();
|
||||||
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString);
|
|
||||||
#else
|
|
||||||
BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString, registryAccess);
|
BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString, registryAccess);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if (!deserializeResult.success)
|
if (!deserializeResult.success)
|
||||||
@@ -360,11 +325,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static BiomeDeserializeResult deserializeBiome(String resourceLocationString) throws IOException
|
|
||||||
#else
|
|
||||||
public static BiomeDeserializeResult deserializeBiome(String resourceLocationString, net.minecraft.core.RegistryAccess registryAccess) throws IOException
|
public static BiomeDeserializeResult deserializeBiome(String resourceLocationString, net.minecraft.core.RegistryAccess registryAccess) throws IOException
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// parse the resource location
|
// parse the resource location
|
||||||
int separatorIndex = resourceLocationString.indexOf(":");
|
int separatorIndex = resourceLocationString.indexOf(":");
|
||||||
@@ -395,10 +356,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
|
|
||||||
|
|
||||||
boolean success;
|
boolean success;
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_17_1
|
||||||
Biome biome = Biome.REGISTRY.getObject(resourceLocation);
|
|
||||||
success = (biome != null);
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
|
Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
|
||||||
success = (biome != null);
|
success = (biome != null);
|
||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
@@ -442,14 +400,10 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
return new BiomeDeserializeResult(success, biome);
|
return new BiomeDeserializeResult(success, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// helper classes //
|
// helper classes //
|
||||||
//================//
|
//================//
|
||||||
//region
|
|
||||||
|
|
||||||
public static class BiomeDeserializeResult
|
public static class BiomeDeserializeResult
|
||||||
{
|
{
|
||||||
@@ -459,21 +413,14 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
public final Biome biome;
|
public final Biome biome;
|
||||||
#else
|
#else
|
||||||
public final Holder<Biome> biome;
|
public final Holder<Biome> biome;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER < MC_1_18_2
|
public BiomeDeserializeResult(boolean success, #if MC_VER < MC_1_18_2 Biome #else Holder<Biome> #endif biome)
|
||||||
public BiomeDeserializeResult(boolean success, Biome biome)
|
|
||||||
#else
|
|
||||||
public BiomeDeserializeResult(boolean success, Holder<Biome> biome)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
this.success = success;
|
this.success = success;
|
||||||
this.biome = biome;
|
this.biome = biome;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+86
-429
@@ -32,20 +32,12 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrappe
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.block.*;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.block.properties.IProperty;
|
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
|
||||||
#else
|
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.world.level.block.BeaconBeamBlock;
|
import net.minecraft.world.level.block.BeaconBeamBlock;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -69,7 +61,7 @@ import net.minecraft.world.level.Level;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.world.level.EmptyBlockGetter;
|
import net.minecraft.world.level.EmptyBlockGetter;
|
||||||
#elif MC_VER > MC_1_12_2
|
#else
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -78,15 +70,12 @@ import net.minecraft.world.level.EmptyBlockGetter;
|
|||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public class BlockStateWrapper implements IBlockStateWrapper
|
public class BlockStateWrapper implements IBlockStateWrapper
|
||||||
{
|
{
|
||||||
/** example "minecraft:water" */
|
/** example "minecraft:water" */
|
||||||
@@ -98,11 +87,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
// must be defined before AIR, otherwise a null pointer will be thrown
|
// must be defined before AIR, otherwise a null pointer will be thrown
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static final ConcurrentHashMap<IBlockState, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>();
|
|
||||||
#else
|
|
||||||
public static final ConcurrentHashMap<BlockState, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<BlockState, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>();
|
||||||
#endif
|
|
||||||
public static final ConcurrentHashMap<String, BlockStateWrapper> WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, BlockStateWrapper> WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static final String AIR_STRING = "AIR";
|
public static final String AIR_STRING = "AIR";
|
||||||
@@ -129,11 +114,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
// properties //
|
// properties //
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public final IBlockState blockState;
|
|
||||||
#else
|
|
||||||
public final BlockState blockState;
|
public final BlockState blockState;
|
||||||
#endif
|
|
||||||
/** technically final, but since it requires a method call to generate it can't be marked as such */
|
/** technically final, but since it requires a method call to generate it can't be marked as such */
|
||||||
private String serialString;
|
private String serialString;
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
@@ -158,71 +139,27 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
// constructors //
|
// constructors //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be faster than BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)
|
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)}
|
||||||
* in cases where the same block state is expected to be referenced multiple times.
|
* in cases where the same block state is expected to be referenced multiple times.
|
||||||
*/
|
*/
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static BlockStateWrapper fromBlockState(IBlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
|
|
||||||
#else
|
|
||||||
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
|
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (guess == null)
|
BlockState guessBlockState = (guess == null || guess.isAir()) ? null : (BlockState) guess.getWrappedMcObject();
|
||||||
{
|
BlockState inputBlockState = (blockState == null || blockState.isAir()) ? null : blockState;
|
||||||
return fromBlockState(blockState, levelWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (guess instanceof BlockStateWrapper
|
||||||
// guess block state
|
&& guessBlockState == inputBlockState)
|
||||||
BlockStateWrapper wrapperGuess = (BlockStateWrapper) guess;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
IBlockState guessBlockState;
|
|
||||||
#else
|
|
||||||
BlockState guessBlockState;
|
|
||||||
#endif
|
|
||||||
if(isAir(wrapperGuess.blockState))
|
|
||||||
{
|
|
||||||
guessBlockState = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
guessBlockState = (IBlockState) guess.getWrappedMcObject();
|
|
||||||
#else
|
|
||||||
guessBlockState = (BlockState) guess.getWrappedMcObject();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// input block state
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
IBlockState inputBlockState;
|
|
||||||
#else
|
|
||||||
BlockState inputBlockState;
|
|
||||||
#endif
|
|
||||||
if (isAir(blockState))
|
|
||||||
{
|
|
||||||
inputBlockState = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inputBlockState = blockState;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (guessBlockState == inputBlockState)
|
|
||||||
{
|
{
|
||||||
return (BlockStateWrapper) guess;
|
return (BlockStateWrapper) guess;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return fromBlockState(blockState, levelWrapper);
|
{
|
||||||
|
return fromBlockState(blockState, levelWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static BlockStateWrapper fromBlockState(@Nullable IBlockState blockState, ILevelWrapper levelWrapper)
|
|
||||||
#else
|
|
||||||
public static BlockStateWrapper fromBlockState(@Nullable BlockState blockState, ILevelWrapper levelWrapper)
|
public static BlockStateWrapper fromBlockState(@Nullable BlockState blockState, ILevelWrapper levelWrapper)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// air is a special case
|
// air is a special case
|
||||||
if (isAir(blockState))
|
if (isAir(blockState))
|
||||||
@@ -271,12 +208,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private BlockStateWrapper(
|
||||||
#if MC_VER <= MC_1_12_2
|
@Nullable BlockState blockState, ILevelWrapper levelWrapper,
|
||||||
private BlockStateWrapper(@Nullable IBlockState blockState, ILevelWrapper levelWrapper, @Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam)
|
@Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam)
|
||||||
#else
|
|
||||||
private BlockStateWrapper(@Nullable BlockState blockState, ILevelWrapper levelWrapper, @Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
this.blockState = blockState;
|
this.blockState = blockState;
|
||||||
this.serialString = serialize(blockState, levelWrapper);
|
this.serialString = serialize(blockState, levelWrapper);
|
||||||
@@ -294,13 +228,11 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
this.isLiquid = this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock;
|
this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty();
|
||||||
#elif MC_VER < MC_1_20_1
|
#else
|
||||||
this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty();
|
|
||||||
#else
|
|
||||||
this.isLiquid = !this.blockState.getFluidState().isEmpty();
|
this.isLiquid = !this.blockState.getFluidState().isEmpty();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,21 +332,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
&& !this.isBeaconBlock)
|
&& !this.isBeaconBlock)
|
||||||
{
|
{
|
||||||
Block block = this.blockState.getBlock();
|
Block block = this.blockState.getBlock();
|
||||||
int colorInt;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
if (block instanceof BlockStainedGlass)
|
|
||||||
{
|
|
||||||
colorInt = blockState.getValue(BlockStainedGlass.COLOR).getColorValue();
|
|
||||||
beaconTintColor = ColorUtil.toColorObjRGB(colorInt);
|
|
||||||
}
|
|
||||||
else if (block instanceof BlockStainedGlassPane)
|
|
||||||
{
|
|
||||||
colorInt = blockState.getValue(BlockStainedGlassPane.COLOR).getColorValue();
|
|
||||||
beaconTintColor = ColorUtil.toColorObjRGB(colorInt);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (block instanceof BeaconBeamBlock)
|
if (block instanceof BeaconBeamBlock)
|
||||||
{
|
{
|
||||||
|
int colorInt;
|
||||||
#if MC_VER <= MC_1_19_4
|
#if MC_VER <= MC_1_19_4
|
||||||
colorInt = ((BeaconBeamBlock) block).getColor().getMaterialColor().col;
|
colorInt = ((BeaconBeamBlock) block).getColor().getMaterialColor().col;
|
||||||
#else
|
#else
|
||||||
@@ -423,7 +343,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
|
|
||||||
beaconTintColor = ColorUtil.toColorObjRGB(colorInt);
|
beaconTintColor = ColorUtil.toColorObjRGB(colorInt);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
this.beaconTintColor = beaconTintColor;
|
this.beaconTintColor = beaconTintColor;
|
||||||
|
|
||||||
@@ -474,9 +393,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
{
|
{
|
||||||
int mcColor = 0;
|
int mcColor = 0;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
mcColor = this.blockState.getMaterial().getMaterialMapColor().colorValue;
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
mcColor = this.blockState.getMaterial().getColor().col;
|
mcColor = this.blockState.getMaterial().getColor().col;
|
||||||
#else
|
#else
|
||||||
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
|
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
|
||||||
@@ -503,7 +420,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
#if MC_VER < MC_1_20_1
|
#if MC_VER < MC_1_20_1
|
||||||
this.isSolid = this.blockState.getMaterial().isSolid();
|
this.isSolid = this.blockState.getMaterial().isSolid();
|
||||||
#else
|
#else
|
||||||
this.isSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty();
|
this.isSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -514,193 +431,76 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
// static constructor helpers //
|
// static constructor helpers //
|
||||||
//region
|
//region
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId(
|
||||||
private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId(@Nullable IBlockState blockState, String lowercaseSerialString, boolean isLiquid)
|
@Nullable BlockState blockState,
|
||||||
#else
|
String lowercaseSerialString,
|
||||||
private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId(@Nullable BlockState blockState, String lowercaseSerialString, boolean isLiquid)
|
boolean isLiquid
|
||||||
#endif
|
)
|
||||||
{
|
{
|
||||||
if (isAir(blockState))
|
if (blockState == null)
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.AIR;
|
return EDhApiBlockMaterial.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (blockState.is(BlockTags.LEAVES)
|
||||||
//========//
|
|
||||||
// leaves //
|
|
||||||
//========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isLeafBlock;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isLeafBlock = blockState.getBlock() instanceof BlockLeaves;
|
|
||||||
#else
|
|
||||||
isLeafBlock = blockState.is(BlockTags.LEAVES);
|
|
||||||
#endif
|
|
||||||
if (isLeafBlock
|
|
||||||
|| lowercaseSerialString.contains("bamboo")
|
|| lowercaseSerialString.contains("bamboo")
|
||||||
|| lowercaseSerialString.contains("cactus")
|
|| lowercaseSerialString.contains("cactus")
|
||||||
|| lowercaseSerialString.contains("chorus_flower")
|
|| lowercaseSerialString.contains("chorus_flower")
|
||||||
|| lowercaseSerialString.contains("mushroom")
|
|| lowercaseSerialString.contains("mushroom")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.LEAVES;
|
return EDhApiBlockMaterial.LEAVES;
|
||||||
}
|
}
|
||||||
|
else if (blockState.is(Blocks.LAVA))
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//======//
|
|
||||||
// lava //
|
|
||||||
//======//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isLavaBlock;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isLavaBlock = blockState.getBlock() == Blocks.LAVA || blockState.getBlock() == Blocks.FLOWING_LAVA;
|
|
||||||
#else
|
|
||||||
isLavaBlock = blockState.is(Blocks.LAVA);
|
|
||||||
#endif
|
|
||||||
if (isLavaBlock)
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.LAVA;
|
return EDhApiBlockMaterial.LAVA;
|
||||||
}
|
}
|
||||||
|
else if (isLiquid
|
||||||
//endregion
|
|| blockState.is(Blocks.WATER))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=======//
|
|
||||||
// water //
|
|
||||||
//=======//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isWaterBlock;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isWaterBlock = blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER;
|
|
||||||
#else
|
|
||||||
isWaterBlock = blockState.is(Blocks.WATER);
|
|
||||||
#endif
|
|
||||||
if (isLiquid
|
|
||||||
|| isWaterBlock)
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.WATER;
|
return EDhApiBlockMaterial.WATER;
|
||||||
}
|
}
|
||||||
|
else if (blockState.getSoundType() == SoundType.WOOD
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//======//
|
|
||||||
// wood //
|
|
||||||
//======//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isWoodSoundingBlock;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isWoodSoundingBlock = blockState.getBlock().getSoundType() == SoundType.WOOD;
|
|
||||||
#else
|
|
||||||
isWoodSoundingBlock = blockState.getSoundType() == SoundType.WOOD;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
boolean isCherryWood;
|
|
||||||
#if MC_VER <= MC_1_19_2
|
|
||||||
isCherryWood = false;
|
|
||||||
#else
|
|
||||||
isCherryWood = blockState.getSoundType() == SoundType.CHERRY_WOOD;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isWoodSoundingBlock
|
|
||||||
|| lowercaseSerialString.contains("root")
|
|| lowercaseSerialString.contains("root")
|
||||||
|| isCherryWood
|
#if MC_VER >= MC_1_19_4
|
||||||
)
|
|| blockState.getSoundType() == SoundType.CHERRY_WOOD
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.WOOD;
|
return EDhApiBlockMaterial.WOOD;
|
||||||
}
|
}
|
||||||
|
else if (blockState.getSoundType() == SoundType.METAL
|
||||||
//endregion
|
#if MC_VER >= MC_1_19_2
|
||||||
|
|| blockState.getSoundType() == SoundType.COPPER
|
||||||
|
#endif
|
||||||
|
#if MC_VER >= MC_1_20_4
|
||||||
//=======//
|
|| blockState.getSoundType() == SoundType.COPPER_BULB
|
||||||
// metal //
|
|| blockState.getSoundType() == SoundType.COPPER_GRATE
|
||||||
//=======//
|
#endif
|
||||||
//region
|
)
|
||||||
|
|
||||||
boolean isMetalSoundingBlock;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isMetalSoundingBlock = blockState.getBlock().getSoundType() == SoundType.METAL;
|
|
||||||
#else
|
|
||||||
isMetalSoundingBlock = blockState.getSoundType() == SoundType.METAL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
boolean isCopperSounding;
|
|
||||||
#if MC_VER <= MC_1_18_2
|
|
||||||
isCopperSounding = false;
|
|
||||||
#elif MC_VER <= MC_1_20_2
|
|
||||||
isCopperSounding = blockState.getSoundType() == SoundType.COPPER;
|
|
||||||
#else
|
|
||||||
isCopperSounding
|
|
||||||
= blockState.getSoundType() == SoundType.COPPER
|
|
||||||
|| blockState.getSoundType() == SoundType.COPPER_BULB
|
|
||||||
|| blockState.getSoundType() == SoundType.COPPER_GRATE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isMetalSoundingBlock
|
|
||||||
|| isCopperSounding)
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.METAL;
|
return EDhApiBlockMaterial.METAL;
|
||||||
}
|
}
|
||||||
|
else if (
|
||||||
//endregion
|
lowercaseSerialString.contains("grass_block")
|
||||||
|
|| lowercaseSerialString.contains("grass_slab")
|
||||||
|
)
|
||||||
|
|
||||||
//=======//
|
|
||||||
// grass //
|
|
||||||
//=======//
|
|
||||||
//region
|
|
||||||
|
|
||||||
if (lowercaseSerialString.contains("grass_block")
|
|
||||||
|| lowercaseSerialString.contains("grass_slab")
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.GRASS;
|
return EDhApiBlockMaterial.GRASS;
|
||||||
}
|
}
|
||||||
|
else if (
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//======//
|
|
||||||
// dirt //
|
|
||||||
//======//
|
|
||||||
//region
|
|
||||||
|
|
||||||
if (
|
|
||||||
lowercaseSerialString.contains("dirt")
|
lowercaseSerialString.contains("dirt")
|
||||||
|| lowercaseSerialString.contains("gravel")
|
|| lowercaseSerialString.contains("gravel")
|
||||||
|| lowercaseSerialString.contains("mud")
|
|| lowercaseSerialString.contains("mud")
|
||||||
|| lowercaseSerialString.contains("podzol")
|
|| lowercaseSerialString.contains("podzol")
|
||||||
|| lowercaseSerialString.contains("mycelium")
|
|| lowercaseSerialString.contains("mycelium")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.DIRT;
|
return EDhApiBlockMaterial.DIRT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===========//
|
|
||||||
// deepslate //
|
|
||||||
//===========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER >= MC_1_17_1
|
||||||
if (blockState.getSoundType() == SoundType.DEEPSLATE
|
else if (blockState.getSoundType() == SoundType.DEEPSLATE
|
||||||
|| blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
|
|| blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
|
||||||
|| blockState.getSoundType() == SoundType.DEEPSLATE_TILES
|
|| blockState.getSoundType() == SoundType.DEEPSLATE_TILES
|
||||||
|| blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
|
|| blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
|
||||||
@@ -709,75 +509,41 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
return EDhApiBlockMaterial.DEEPSLATE;
|
return EDhApiBlockMaterial.DEEPSLATE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if (lowercaseSerialString.contains("snow"))
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============//
|
|
||||||
// netherrack //
|
|
||||||
//============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isNetherRack;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isNetherRack = blockState.getBlock() == Blocks.NETHERRACK;
|
|
||||||
#else
|
|
||||||
isNetherRack = blockState.is(BlockTags.BASE_STONE_NETHER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isNetherRack)
|
|
||||||
{
|
|
||||||
return EDhApiBlockMaterial.NETHER_STONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
|
||||||
// misc/simple //
|
|
||||||
//=============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
if (lowercaseSerialString.contains("snow"))
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.SNOW;
|
return EDhApiBlockMaterial.SNOW;
|
||||||
}
|
}
|
||||||
|
else if (lowercaseSerialString.contains("sand"))
|
||||||
if (lowercaseSerialString.contains("sand"))
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.SAND;
|
return EDhApiBlockMaterial.SAND;
|
||||||
}
|
}
|
||||||
|
else if (lowercaseSerialString.contains("terracotta"))
|
||||||
if (lowercaseSerialString.contains("terracotta"))
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.TERRACOTTA;
|
return EDhApiBlockMaterial.TERRACOTTA;
|
||||||
}
|
}
|
||||||
|
else if (blockState.is(BlockTags.BASE_STONE_NETHER))
|
||||||
if (lowercaseSerialString.contains("stone")
|
{
|
||||||
|
return EDhApiBlockMaterial.NETHER_STONE;
|
||||||
|
}
|
||||||
|
else if (lowercaseSerialString.contains("stone")
|
||||||
|| lowercaseSerialString.contains("ore"))
|
|| lowercaseSerialString.contains("ore"))
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.STONE;
|
return EDhApiBlockMaterial.STONE;
|
||||||
}
|
}
|
||||||
|
else if (blockState.getLightEmission() > 0)
|
||||||
if (getLightEmission(blockState) > 0)
|
|
||||||
{
|
{
|
||||||
return EDhApiBlockMaterial.ILLUMINATED;
|
return EDhApiBlockMaterial.ILLUMINATED;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
//endregion
|
{
|
||||||
|
return EDhApiBlockMaterial.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
return EDhApiBlockMaterial.UNKNOWN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
private static int calculateOpacity(
|
||||||
private static int calculateOpacity(@Nullable IBlockState blockState, boolean isAir, boolean isLiquid)
|
@Nullable BlockState blockState,
|
||||||
#else
|
boolean isAir, boolean isLiquid
|
||||||
private static int calculateOpacity(@Nullable BlockState blockState, boolean isAir, boolean isLiquid)
|
)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// get block properties (defaults to the values used by air)
|
// get block properties (defaults to the values used by air)
|
||||||
boolean canOcclude = getCanOcclude(blockState);
|
boolean canOcclude = getCanOcclude(blockState);
|
||||||
@@ -816,40 +582,24 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
|
|
||||||
return opacity;
|
return opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static boolean getCanOcclude(@Nullable IBlockState blockState)
|
|
||||||
#else
|
|
||||||
private static boolean getCanOcclude(@Nullable BlockState blockState)
|
private static boolean getCanOcclude(@Nullable BlockState blockState)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// defaults to the value used by air
|
// defaults to the value used by air
|
||||||
boolean canOcclude = false;
|
boolean canOcclude = false;
|
||||||
if (blockState != null)
|
if (blockState != null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
canOcclude = blockState.getMaterial().isSolid();
|
|
||||||
#else
|
|
||||||
canOcclude = blockState.canOcclude();
|
canOcclude = blockState.canOcclude();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return canOcclude;
|
return canOcclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static boolean getPropagatesSkyLightDown(@Nullable IBlockState blockState)
|
|
||||||
#else
|
|
||||||
private static boolean getPropagatesSkyLightDown(@Nullable BlockState blockState)
|
private static boolean getPropagatesSkyLightDown(@Nullable BlockState blockState)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// defaults to the value used by air
|
// defaults to the value used by air
|
||||||
boolean propagatesSkyLightDown = true;
|
boolean propagatesSkyLightDown = true;
|
||||||
if (blockState != null)
|
if (blockState != null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_3
|
||||||
propagatesSkyLightDown = blockState.getBlock().getLightOpacity(blockState) == 0;
|
|
||||||
#elif MC_VER < MC_1_21_3
|
|
||||||
propagatesSkyLightDown = blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
propagatesSkyLightDown = blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||||
#else
|
#else
|
||||||
propagatesSkyLightDown = blockState.propagatesSkylightDown();
|
propagatesSkyLightDown = blockState.propagatesSkylightDown();
|
||||||
@@ -909,10 +659,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
return waterSurfaceReplacementBlocks;
|
return waterSurfaceReplacementBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectOpenHashSet<String> baseIgnoredBlockResourceSet = new ObjectOpenHashSet<>();
|
ObjectOpenHashSet<String> baseIgnoredBlock = new ObjectOpenHashSet<>();
|
||||||
waterSurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSurfaceBlockReplacementCsv, baseIgnoredBlockResourceSet, levelWrapper);
|
waterSurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSurfaceBlockReplacementCsv, baseIgnoredBlock, levelWrapper);
|
||||||
waterSubsurfaceReplacementBlocks.remove(AIR);
|
|
||||||
|
|
||||||
return waterSurfaceReplacementBlocks;
|
return waterSurfaceReplacementBlocks;
|
||||||
}
|
}
|
||||||
public static ObjectOpenHashSet<IBlockStateWrapper> getWaterSubsurfaceReplacementBlocks(ILevelWrapper levelWrapper)
|
public static ObjectOpenHashSet<IBlockStateWrapper> getWaterSubsurfaceReplacementBlocks(ILevelWrapper levelWrapper)
|
||||||
@@ -923,12 +671,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
return waterSubsurfaceReplacementBlocks;
|
return waterSubsurfaceReplacementBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectOpenHashSet<String> baseIgnoredBlockResourceSet = new ObjectOpenHashSet<>();
|
ObjectOpenHashSet<String> baseIgnoredBlock = new ObjectOpenHashSet<>();
|
||||||
waterSubsurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSubSurfaceBlockReplacementCsv, baseIgnoredBlockResourceSet, levelWrapper);
|
waterSubsurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSubSurfaceBlockReplacementCsv, baseIgnoredBlock, levelWrapper);
|
||||||
// air will be present if any invalid resource locations are present
|
|
||||||
// but we don't want to replace air with water, that'll cause monoliths
|
|
||||||
waterSubsurfaceReplacementBlocks.remove(AIR);
|
|
||||||
|
|
||||||
return waterSubsurfaceReplacementBlocks;
|
return waterSubsurfaceReplacementBlocks;
|
||||||
}
|
}
|
||||||
public static IBlockStateWrapper getWaterBlockStateWrapper(ILevelWrapper levelWrapper)
|
public static IBlockStateWrapper getWaterBlockStateWrapper(ILevelWrapper levelWrapper)
|
||||||
@@ -996,17 +740,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
if (defaultBlockStateToIgnore != AIR)
|
if (defaultBlockStateToIgnore != AIR)
|
||||||
{
|
{
|
||||||
// add all possible blockstates (to account for light blocks with different light values and such)
|
// add all possible blockstates (to account for light blocks with different light values and such)
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
List<IBlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getBlockState().getValidStates();
|
|
||||||
#else
|
|
||||||
List<BlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
|
List<BlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
for (IBlockState blockState : blockStatesToIgnore)
|
|
||||||
#else
|
|
||||||
for (BlockState blockState : blockStatesToIgnore)
|
for (BlockState blockState : blockStatesToIgnore)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
BlockStateWrapper newBlockToIgnore = fromBlockState(blockState, levelWrapper);
|
BlockStateWrapper newBlockToIgnore = fromBlockState(blockState, levelWrapper);
|
||||||
blockStateWrappers.add(newBlockToIgnore);
|
blockStateWrappers.add(newBlockToIgnore);
|
||||||
@@ -1053,25 +788,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
public int getOpacity() { return this.opacity; }
|
public int getOpacity() { return this.opacity; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightEmission() { return getLightEmission(this.blockState); }
|
public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; }
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static int getLightEmission(IBlockState blockState)
|
|
||||||
#else
|
|
||||||
public static int getLightEmission(BlockState blockState)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (blockState == null)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return blockState.getLightValue();
|
|
||||||
#else
|
|
||||||
return blockState.getLightEmission();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSerialString() { return this.serialString; }
|
public String getSerialString() { return this.serialString; }
|
||||||
@@ -1081,23 +798,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAir() { return isAir(this.blockState); }
|
public boolean isAir() { return isAir(this.blockState); }
|
||||||
#if MC_VER <= MC_1_12_2
|
public static boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
|
||||||
public static boolean isAir(IBlockState blockState)
|
|
||||||
#else
|
|
||||||
public static boolean isAir(BlockState blockState)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (blockState == null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return blockState.getBlock() == Blocks.AIR;
|
|
||||||
#else
|
|
||||||
return blockState.isAir();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSolid() { return this.isSolid; }
|
public boolean isSolid() { return this.isSolid; }
|
||||||
@@ -1131,11 +832,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
//=======================//
|
//=======================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static String serialize(IBlockState blockState, ILevelWrapper levelWrapper)
|
|
||||||
#else
|
|
||||||
private static String serialize(BlockState blockState, ILevelWrapper levelWrapper)
|
private static String serialize(BlockState blockState, ILevelWrapper levelWrapper)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (blockState == null)
|
if (blockState == null)
|
||||||
{
|
{
|
||||||
@@ -1157,9 +854,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
Identifier resourceLocation;
|
Identifier resourceLocation;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_17_1
|
||||||
resourceLocation = blockState.getBlock().getRegistryName();
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
resourceLocation = Registry.BLOCK.getKey(blockState.getBlock());
|
resourceLocation = Registry.BLOCK.getKey(blockState.getBlock());
|
||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(blockState.getBlock());
|
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(blockState.getBlock());
|
||||||
@@ -1258,9 +953,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Block block;
|
Block block;
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_17_1
|
||||||
block = Block.REGISTRY.getObject(resourceLocation);
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
block = Registry.BLOCK.get(resourceLocation);
|
block = Registry.BLOCK.get(resourceLocation);
|
||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
|
||||||
@@ -1289,24 +982,11 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
|
|
||||||
|
|
||||||
// attempt to find the blockstate from all possibilities
|
// attempt to find the blockstate from all possibilities
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
IBlockState foundState = null;
|
|
||||||
#else
|
|
||||||
BlockState foundState = null;
|
BlockState foundState = null;
|
||||||
#endif
|
|
||||||
if (blockStatePropertiesString != null)
|
if (blockStatePropertiesString != null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
List<IBlockState> possibleStateList = block.getBlockState().getValidStates();
|
|
||||||
#else
|
|
||||||
List<BlockState> possibleStateList = block.getStateDefinition().getPossibleStates();
|
List<BlockState> possibleStateList = block.getStateDefinition().getPossibleStates();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
for (IBlockState possibleState : possibleStateList)
|
|
||||||
#else
|
|
||||||
for (BlockState possibleState : possibleStateList)
|
for (BlockState possibleState : possibleStateList)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
String possibleStatePropertiesString = serializeBlockStateProperties(possibleState);
|
String possibleStatePropertiesString = serializeBlockStateProperties(possibleState);
|
||||||
if (possibleStatePropertiesString.equals(blockStatePropertiesString))
|
if (possibleStatePropertiesString.equals(blockStatePropertiesString))
|
||||||
@@ -1330,12 +1010,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
foundState = block.getDefaultState();
|
|
||||||
#else
|
|
||||||
foundState = block.defaultBlockState();
|
foundState = block.defaultBlockState();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foundWrapper = fromBlockState(foundState, levelWrapper);
|
foundWrapper = fromBlockState(foundState, levelWrapper);
|
||||||
@@ -1360,44 +1035,26 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** used to compare and save BlockStates based on their properties */
|
/** used to compare and save BlockStates based on their properties */
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static String serializeBlockStateProperties(IBlockState blockState)
|
|
||||||
#else
|
|
||||||
private static String serializeBlockStateProperties(BlockState blockState)
|
private static String serializeBlockStateProperties(BlockState blockState)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// get the property list for this block (doesn't contain this block state's values, just the names and possible values)
|
// get the property list for this block (doesn't contain this block state's values, just the names and possible values)
|
||||||
#if MC_VER <= MC_1_12_2
|
java.util.Collection<net.minecraft.world.level.block.state.properties.Property<?>> blockPropertyCollection = blockState.getProperties();
|
||||||
java.util.Collection<IProperty<?>> blockPropertyCollection = blockState.getPropertyKeys();
|
|
||||||
List<IProperty<?>> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
|
|
||||||
#else
|
|
||||||
java.util.Collection<net.minecraft.world.level.block.state.properties.Property<?>> blockPropertyCollection = blockState.getProperties();;
|
|
||||||
List<net.minecraft.world.level.block.state.properties.Property<?>> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// alphabetically sort the list so they are always in the same order
|
// alphabetically sort the list so they are always in the same order
|
||||||
|
List<net.minecraft.world.level.block.state.properties.Property<?>> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
|
||||||
sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName()));
|
sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName()));
|
||||||
|
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
for (IProperty<?> property : sortedBlockPropteryList)
|
|
||||||
#else
|
|
||||||
for (net.minecraft.world.level.block.state.properties.Property<?> property : sortedBlockPropteryList)
|
for (net.minecraft.world.level.block.state.properties.Property<?> property : sortedBlockPropteryList)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
String propertyName = property.getName();
|
String propertyName = property.getName();
|
||||||
|
|
||||||
String value = "NULL";
|
String value = "NULL";
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
value = blockState.getValue(property).toString();
|
|
||||||
#else
|
|
||||||
if (blockState.hasProperty(property))
|
if (blockState.hasProperty(property))
|
||||||
{
|
{
|
||||||
value = blockState.getValue(property).toString();
|
value = blockState.getValue(property).toString();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
stringBuilder.append("{");
|
stringBuilder.append("{");
|
||||||
stringBuilder.append(propertyName).append(RESOURCE_LOCATION_SEPARATOR).append(value);
|
stringBuilder.append(propertyName).append(RESOURCE_LOCATION_SEPARATOR).append(value);
|
||||||
|
|||||||
+55
-251
@@ -32,31 +32,22 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapp
|
|||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.util.EnumBlockRenderType;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.block.BlockRotatedPillar;
|
|
||||||
import net.minecraft.block.*;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.client.renderer.color.BlockColors;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
#else
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
#if MC_VER >= MC_1_19_2
|
#if MC_VER >= MC_1_19_2
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
#else
|
#else
|
||||||
|
import java.util.Random;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER < MC_1_21_5
|
#if MC_VER < MC_1_21_5
|
||||||
@@ -73,7 +64,7 @@ import net.minecraft.client.color.block.BlockTintSource;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This stores and calculates the colors
|
* This stores and calculates the colors
|
||||||
* the given BlockState should have based
|
* the given {@link BlockState} should have based
|
||||||
* on the given {@link IClientLevelWrapper}.
|
* on the given {@link IClientLevelWrapper}.
|
||||||
*
|
*
|
||||||
* @see ColorUtil
|
* @see ColorUtil
|
||||||
@@ -82,23 +73,10 @@ public class ClientBlockStateColorCache
|
|||||||
{
|
{
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final Minecraft MC = Minecraft.getMinecraft();
|
|
||||||
#else
|
|
||||||
private static final Minecraft MC = Minecraft.getInstance();
|
private static final Minecraft MC = Minecraft.getInstance();
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#else
|
|
||||||
private static final HashSet<BlockState> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>();
|
private static final HashSet<BlockState> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final HashSet<IBlockState> BROKEN_BLOCK_STATES = new HashSet<>();
|
|
||||||
#else
|
|
||||||
private static final HashSet<BlockState> BROKEN_BLOCK_STATES = new HashSet<>();
|
private static final HashSet<BlockState> BROKEN_BLOCK_STATES = new HashSet<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods using MC's "RandomSource" object aren't thread safe <br>
|
* Methods using MC's "RandomSource" object aren't thread safe <br>
|
||||||
@@ -110,22 +88,8 @@ public class ClientBlockStateColorCache
|
|||||||
*/
|
*/
|
||||||
private static final ReentrantLock RESOLVE_LOCK = new ReentrantLock();
|
private static final ReentrantLock RESOLVE_LOCK = new ReentrantLock();
|
||||||
|
|
||||||
public static final int INVALID_COLOR = -1;
|
|
||||||
|
|
||||||
|
|
||||||
/** This is the order each direction on a block is processed when attempting to get the texture/color */
|
/** This is the order each direction on a block is processed when attempting to get the texture/color */
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final @Nullable EnumFacing[] COLOR_RESOLUTION_DIRECTION_ORDER =
|
|
||||||
{
|
|
||||||
EnumFacing.UP,
|
|
||||||
null, // null represents "unculled" faces, IE the top of farmland
|
|
||||||
EnumFacing.NORTH,
|
|
||||||
EnumFacing.EAST,
|
|
||||||
EnumFacing.WEST,
|
|
||||||
EnumFacing.SOUTH,
|
|
||||||
EnumFacing.DOWN
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
private static final @Nullable Direction[] COLOR_RESOLUTION_DIRECTION_ORDER =
|
private static final @Nullable Direction[] COLOR_RESOLUTION_DIRECTION_ORDER =
|
||||||
{
|
{
|
||||||
Direction.UP,
|
Direction.UP,
|
||||||
@@ -136,7 +100,6 @@ public class ClientBlockStateColorCache
|
|||||||
Direction.SOUTH,
|
Direction.SOUTH,
|
||||||
Direction.DOWN
|
Direction.DOWN
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
private static final int FLOWER_COLOR_SCALE = 5;
|
private static final int FLOWER_COLOR_SCALE = 5;
|
||||||
|
|
||||||
@@ -150,11 +113,7 @@ public class ClientBlockStateColorCache
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private final IClientLevelWrapper clientLevelWrapper;
|
private final IClientLevelWrapper clientLevelWrapper;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final IBlockState blockState;
|
|
||||||
#else
|
|
||||||
private final BlockState blockState;
|
private final BlockState blockState;
|
||||||
#endif
|
|
||||||
private final BlockStateWrapper blockStateWrapper;
|
private final BlockStateWrapper blockStateWrapper;
|
||||||
|
|
||||||
private boolean isColorResolved = false;
|
private boolean isColorResolved = false;
|
||||||
@@ -232,10 +191,8 @@ public class ClientBlockStateColorCache
|
|||||||
};
|
};
|
||||||
|
|
||||||
// these are threadlocals since AbstractDhTintGetter use local variables to handle color queries
|
// these are threadlocals since AbstractDhTintGetter use local variables to handle color queries
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
private static final ThreadLocal<TintWithoutLevelOverrider> TintWithoutLevelOverrideGetter = ThreadLocal.withInitial(TintWithoutLevelOverrider::new);
|
private static final ThreadLocal<TintWithoutLevelOverrider> TintWithoutLevelOverrideGetter = ThreadLocal.withInitial(TintWithoutLevelOverrider::new);
|
||||||
private static final ThreadLocal<TintGetterOverride> TintOverrideGetter = ThreadLocal.withInitial(TintGetterOverride::new);
|
private static final ThreadLocal<TintGetterOverride> TintOverrideGetter = ThreadLocal.withInitial(TintGetterOverride::new);
|
||||||
#endif
|
|
||||||
private static final ThreadLocal<DhApiBlockColorOverrideEvent.EventParam> ColorOverrideEventParamGetter = ThreadLocal.withInitial(DhApiBlockColorOverrideEvent.EventParam::new);
|
private static final ThreadLocal<DhApiBlockColorOverrideEvent.EventParam> ColorOverrideEventParamGetter = ThreadLocal.withInitial(DhApiBlockColorOverrideEvent.EventParam::new);
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -247,11 +204,7 @@ public class ClientBlockStateColorCache
|
|||||||
//=============//
|
//=============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public ClientBlockStateColorCache(IBlockState blockState, IClientLevelWrapper clientLevelWrapper)
|
|
||||||
#else
|
|
||||||
public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper)
|
public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
this.blockState = blockState;
|
this.blockState = blockState;
|
||||||
this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper);
|
this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper);
|
||||||
@@ -267,7 +220,6 @@ public class ClientBlockStateColorCache
|
|||||||
//===================//
|
//===================//
|
||||||
// color calculation //
|
// color calculation //
|
||||||
//===================//
|
//===================//
|
||||||
//region
|
|
||||||
|
|
||||||
private void resolveColors()
|
private void resolveColors()
|
||||||
{
|
{
|
||||||
@@ -281,44 +233,17 @@ public class ClientBlockStateColorCache
|
|||||||
// getQuads() isn't thread safe so we need to put this logic in a lock
|
// getQuads() isn't thread safe so we need to put this logic in a lock
|
||||||
RESOLVE_LOCK.lock();
|
RESOLVE_LOCK.lock();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
if (this.blockState.getFluidState().isEmpty())
|
||||||
if (this.blockState.getRenderType() == EnumBlockRenderType.ENTITYBLOCK_ANIMATED)
|
|
||||||
{
|
|
||||||
this.needPostTinting = false;
|
|
||||||
this.tintIndex = 0;
|
|
||||||
this.baseColor = ColorUtil.argbToInt(255,
|
|
||||||
this.blockStateWrapper.getMapColor().getRed(),
|
|
||||||
this.blockStateWrapper.getMapColor().getGreen(),
|
|
||||||
this.blockStateWrapper.getMapColor().getBlue());
|
|
||||||
this.isColorResolved = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!this.blockStateWrapper.isLiquid())
|
|
||||||
{
|
{
|
||||||
// look for the first non-empty direction
|
// look for the first non-empty direction
|
||||||
List<BakedQuad> quads = null;
|
List<BakedQuad> quads = null;
|
||||||
|
for (Direction direction : COLOR_RESOLUTION_DIRECTION_ORDER)
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
EnumFacing direction;
|
|
||||||
#else
|
|
||||||
Direction direction;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < COLOR_RESOLUTION_DIRECTION_ORDER.length; i++)
|
|
||||||
{
|
{
|
||||||
direction = COLOR_RESOLUTION_DIRECTION_ORDER[i];
|
|
||||||
quads = this.getQuadsForDirection(direction);
|
quads = this.getQuadsForDirection(direction);
|
||||||
if (quads != null && !quads.isEmpty()
|
if (quads != null && !quads.isEmpty()
|
||||||
&& !(
|
&& !(
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.blockState.getBlock() instanceof BlockRotatedPillar
|
|
||||||
&& direction == EnumFacing.UP
|
|
||||||
#else
|
|
||||||
this.blockState.getBlock() instanceof RotatedPillarBlock
|
this.blockState.getBlock() instanceof RotatedPillarBlock
|
||||||
&& direction == Direction.UP
|
&& direction == Direction.UP
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -339,9 +264,7 @@ public class ClientBlockStateColorCache
|
|||||||
{
|
{
|
||||||
BakedQuad firstQuad = quads.get(0);
|
BakedQuad firstQuad = quads.get(0);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
this.needPostTinting = firstQuad.hasTintIndex();
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
this.needPostTinting = firstQuad.isTinted();
|
this.needPostTinting = firstQuad.isTinted();
|
||||||
#else
|
#else
|
||||||
this.needPostTinting = firstQuad.materialInfo().isTinted();
|
this.needPostTinting = firstQuad.materialInfo().isTinted();
|
||||||
@@ -355,7 +278,7 @@ public class ClientBlockStateColorCache
|
|||||||
this.tintIndex = firstQuad.materialInfo().tintIndex();
|
this.tintIndex = firstQuad.materialInfo().tintIndex();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER < MC_1_17_1 && MC_VER > MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
this.baseColor = calculateColorFromTexture(
|
this.baseColor = calculateColorFromTexture(
|
||||||
firstQuad.sprite,
|
firstQuad.sprite,
|
||||||
EColorMode.getColorMode(this.blockState.getBlock()));
|
EColorMode.getColorMode(this.blockState.getBlock()));
|
||||||
@@ -415,43 +338,20 @@ public class ClientBlockStateColorCache
|
|||||||
@Nullable
|
@Nullable
|
||||||
private List<BakedQuad> getUnculledQuads() { return this.getQuadsForDirection(null); }
|
private List<BakedQuad> getUnculledQuads() { return this.getQuadsForDirection(null); }
|
||||||
@Nullable
|
@Nullable
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private List<BakedQuad> getQuadsForDirection(@Nullable EnumFacing direction)
|
|
||||||
#else
|
|
||||||
private List<BakedQuad> getQuadsForDirection(@Nullable Direction direction)
|
private List<BakedQuad> getQuadsForDirection(@Nullable Direction direction)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
IBlockState effectiveBlockState = this.blockState;
|
|
||||||
#else
|
|
||||||
BlockState effectiveBlockState = this.blockState;
|
BlockState effectiveBlockState = this.blockState;
|
||||||
#endif
|
|
||||||
|
|
||||||
// if this block is a slab, use it's double variant so we can get the top face,
|
// 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
|
// otherwise the color will use the side, which isn't as accurate
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
if (this.blockState.getBlock() instanceof BlockSlab && !((BlockSlab) this.blockState.getBlock()).isDouble())
|
|
||||||
{
|
|
||||||
effectiveBlockState = this.blockState.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (this.blockState.getBlock() instanceof SlabBlock)
|
if (this.blockState.getBlock() instanceof SlabBlock)
|
||||||
{
|
{
|
||||||
effectiveBlockState = this.blockState.setValue( SlabBlock.TYPE, SlabType.DOUBLE );
|
effectiveBlockState = this.blockState.setValue( SlabBlock.TYPE, SlabType.DOUBLE );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
List<BakedQuad> quads;
|
List<BakedQuad> quads;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_5
|
||||||
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().
|
quads = MC.getModelManager().getBlockModelShaper().
|
||||||
getBlockModel(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM);
|
getBlockModel(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM);
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
@@ -508,18 +408,10 @@ public class ClientBlockStateColorCache
|
|||||||
//_ OpenGL RGBA format Java Order: 0xAA BB GG RR
|
//_ OpenGL RGBA format Java Order: 0xAA BB GG RR
|
||||||
tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v);
|
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 r = (tempColor & 0x000000FF);
|
||||||
int g = (tempColor & 0x0000FF00) >>> 8;
|
int g = (tempColor & 0x0000FF00) >>> 8;
|
||||||
int b = (tempColor & 0x00FF0000) >>> 16;
|
int b = (tempColor & 0x00FF0000) >>> 16;
|
||||||
int a = (tempColor & 0xFF000000) >>> 24;
|
int a = (tempColor & 0xFF000000) >>> 24;
|
||||||
#endif
|
|
||||||
|
|
||||||
int scale = 1;
|
int scale = 1;
|
||||||
if (colorMode == EColorMode.Leaves)
|
if (colorMode == EColorMode.Leaves)
|
||||||
{
|
{
|
||||||
@@ -576,9 +468,7 @@ public class ClientBlockStateColorCache
|
|||||||
}
|
}
|
||||||
private static int getTextureWidth(TextureAtlasSprite texture)
|
private static int getTextureWidth(TextureAtlasSprite texture)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_4
|
||||||
return texture.getIconWidth();
|
|
||||||
#elif MC_VER < MC_1_19_4
|
|
||||||
return texture.getWidth();
|
return texture.getWidth();
|
||||||
#else
|
#else
|
||||||
return texture.contents().width();
|
return texture.contents().width();
|
||||||
@@ -586,9 +476,7 @@ public class ClientBlockStateColorCache
|
|||||||
}
|
}
|
||||||
private static int getTextureHeight(TextureAtlasSprite texture)
|
private static int getTextureHeight(TextureAtlasSprite texture)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_4
|
||||||
return texture.getIconHeight();
|
|
||||||
#elif MC_VER < MC_1_19_4
|
|
||||||
return texture.getHeight();
|
return texture.getHeight();
|
||||||
#else
|
#else
|
||||||
return texture.contents().height();
|
return texture.contents().height();
|
||||||
@@ -622,9 +510,7 @@ public class ClientBlockStateColorCache
|
|||||||
private int getParticleIconColor()
|
private int getParticleIconColor()
|
||||||
{
|
{
|
||||||
return calculateColorFromTexture(
|
return calculateColorFromTexture(
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(this.blockState),
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(this.blockState),
|
Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(this.blockState),
|
||||||
#else
|
#else
|
||||||
Minecraft.getInstance().getModelManager().getBlockStateModelSet().get(this.blockState).particleMaterial().sprite(),
|
Minecraft.getInstance().getModelManager().getBlockStateModelSet().get(this.blockState).particleMaterial().sprite(),
|
||||||
@@ -632,20 +518,16 @@ public class ClientBlockStateColorCache
|
|||||||
EColorMode.getColorMode(this.blockState.getBlock()));
|
EColorMode.getColorMode(this.blockState.getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===============//
|
//===============//
|
||||||
// public getter //
|
// public getter //
|
||||||
//===============//
|
//===============//
|
||||||
//region
|
|
||||||
|
|
||||||
public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos)
|
public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos)
|
||||||
{
|
{
|
||||||
// only get the tint if the block needs to be tinted
|
// only get the tint if the block needs to be tinted
|
||||||
int tintColor = ClientBlockStateColorCache.INVALID_COLOR;
|
int tintColor = AbstractDhTintGetter.INVALID_COLOR;
|
||||||
|
|
||||||
if (this.needPostTinting)
|
if (this.needPostTinting)
|
||||||
{
|
{
|
||||||
// don't try tinting blocks that don't support our method of tint getting
|
// don't try tinting blocks that don't support our method of tint getting
|
||||||
@@ -658,40 +540,6 @@ public class ClientBlockStateColorCache
|
|||||||
// attempt to get the tint
|
// attempt to get the tint
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
// 1.12.2 doesn't have BlockAndTintGetter -> get tintColor from biome
|
|
||||||
WorldClient world = (WorldClient) this.clientLevelWrapper.getWrappedMcObject();
|
|
||||||
BlockPos mcPos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
|
||||||
|
|
||||||
Block block = this.blockState.getBlock();
|
|
||||||
if (block instanceof BlockGrass
|
|
||||||
|| block instanceof BlockBush)
|
|
||||||
{
|
|
||||||
tintColor = biomeWrapper.biome.getGrassColorAtPos(mcPos);
|
|
||||||
}
|
|
||||||
else if (block instanceof BlockLeaves)
|
|
||||||
{
|
|
||||||
tintColor = biomeWrapper.biome.getFoliageColorAtPos(mcPos);
|
|
||||||
}
|
|
||||||
else if (block instanceof BlockLiquid) // We don't want lava to fall into the else block
|
|
||||||
{
|
|
||||||
if(block == Blocks.WATER
|
|
||||||
|| block == Blocks.FLOWING_WATER)
|
|
||||||
{
|
|
||||||
tintColor = biomeWrapper.biome.getWaterColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
|
|
||||||
tintColor = blockColors.colorMultiplier(blockState, world, mcPos, this.tintIndex);
|
|
||||||
|
|
||||||
if (tintColor == ClientBlockStateColorCache.INVALID_COLOR)
|
|
||||||
{
|
|
||||||
tintColor = blockColors.getColor(blockState, world, mcPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// try to use the fast tint getter logic first
|
// try to use the fast tint getter logic first
|
||||||
if (!BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
|
if (!BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
|
||||||
{
|
{
|
||||||
@@ -702,18 +550,18 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
// try using DH's cached tint values first if possible
|
// try using DH's cached tint values first if possible
|
||||||
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
|
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
|
||||||
if (tintColor == ClientBlockStateColorCache.INVALID_COLOR)
|
if (tintColor == AbstractDhTintGetter.INVALID_COLOR)
|
||||||
{
|
{
|
||||||
// one or more tint values weren't calculated,
|
// one or more tint values weren't calculated,
|
||||||
// we need MC's color resolver
|
// we need MC's color resolver
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
tintColor = Minecraft.getInstance()
|
tintColor = Minecraft.getInstance()
|
||||||
.getBlockColors()
|
.getBlockColors()
|
||||||
.getColor(this.blockState,
|
.getColor(this.blockState,
|
||||||
tintOverride, // tintOverride will save the result of this query to speed up future queries
|
tintOverride, // tintOverride will save the result of this query to speed up future queries
|
||||||
McObjectConverter.Convert(blockPos),
|
McObjectConverter.Convert(blockPos),
|
||||||
this.tintIndex);
|
this.tintIndex);
|
||||||
#else
|
#else
|
||||||
BlockTintSource tintSource = Minecraft.getInstance()
|
BlockTintSource tintSource = Minecraft.getInstance()
|
||||||
.getBlockColors()
|
.getBlockColors()
|
||||||
.getTintSource(this.blockState, this.tintIndex);
|
.getTintSource(this.blockState, this.tintIndex);
|
||||||
@@ -724,12 +572,18 @@ public class ClientBlockStateColorCache
|
|||||||
{
|
{
|
||||||
BlockPos mcPos = McObjectConverter.Convert(blockPos);
|
BlockPos mcPos = McObjectConverter.Convert(blockPos);
|
||||||
tintColor = tintSource.colorInWorld(this.blockState, tintOverride, mcPos);
|
tintColor = tintSource.colorInWorld(this.blockState, tintOverride, mcPos);
|
||||||
if (tintColor == ClientBlockStateColorCache.INVALID_COLOR)
|
if (tintColor == -1)
|
||||||
{
|
{
|
||||||
tintColor = tintSource.colorAsTerrainParticle(this.blockState, tintOverride, mcPos);
|
tintColor = tintSource.colorAsTerrainParticle(this.blockState, tintOverride, mcPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tintColor == -1)
|
||||||
|
{
|
||||||
|
// no color found, use the base color
|
||||||
|
tintColor = AbstractDhTintGetter.INVALID_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
// save this color to speed up future queries
|
// save this color to speed up future queries
|
||||||
TintWithoutLevelOverrider.setStaticColor(this.blockStateWrapper, biomeWrapper, tintColor);
|
TintWithoutLevelOverrider.setStaticColor(this.blockStateWrapper, biomeWrapper, tintColor);
|
||||||
// try to get the blended color with this new information
|
// try to get the blended color with this new information
|
||||||
@@ -739,47 +593,44 @@ public class ClientBlockStateColorCache
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
// this exception generally occurs if the tint requires other blocks besides itself
|
// this exception generally occurs if the tint requires other blocks besides itself
|
||||||
LOGGER.debug("Unable to use ["+ TintWithoutLevelOverrider.class.getSimpleName()+"] to get the block tint for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Attempting to use backup method...", e);
|
LOGGER.debug("Unable to use ["+ TintWithoutLevelOverrider.class.getSimpleName()+"] to get the block tint for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Attempting to use backup method...", e);
|
||||||
BLOCK_STATES_THAT_NEED_LEVEL.add(this.blockState);
|
BLOCK_STATES_THAT_NEED_LEVEL.add(this.blockState);
|
||||||
#else
|
#else
|
||||||
// only display the error once per block/biome type to reduce log spam
|
// only display the error once per block/biome type to reduce log spam
|
||||||
if (!BROKEN_BLOCK_STATES.contains(this.blockState))
|
if (!BROKEN_BLOCK_STATES.contains(this.blockState))
|
||||||
{
|
{
|
||||||
LOGGER.warn("Failed to get block color for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Note: future errors for this block/biome will be ignored.", e);
|
LOGGER.warn("Failed to get block color for block: [" + this.blockState + "] and biome: [" + biomeWrapper + "] at pos: " + blockPos + ". Error: [" + e.getMessage() + "]. Note: future errors for this block/biome will be ignored.", e);
|
||||||
BROKEN_BLOCK_STATES.add(this.blockState);
|
BROKEN_BLOCK_STATES.add(this.blockState);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// level-specific logic is only needed for MC 1.21.11 and older
|
// level-specific logic is only needed for MC 1.21.11 and older
|
||||||
#if MC_VER <= MC_1_21_11 && MC_VER > MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
// use the level logic only if requested
|
// use the level logic only if requested
|
||||||
if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
|
if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
|
||||||
|
{
|
||||||
|
// the level shouldn't be used all the time due to it breaking some blocks tinting
|
||||||
|
// specifically oceans don't render correctly
|
||||||
|
|
||||||
|
TintGetterOverride tintOverride = TintOverrideGetter.get();
|
||||||
|
tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper);
|
||||||
|
|
||||||
|
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
|
||||||
|
if (tintColor == AbstractDhTintGetter.INVALID_COLOR)
|
||||||
{
|
{
|
||||||
// the level shouldn't be used all the time due to it breaking some blocks tinting
|
tintColor = Minecraft.getInstance()
|
||||||
// specifically oceans don't render correctly
|
.getBlockColors()
|
||||||
|
.getColor(this.blockState,
|
||||||
TintGetterOverride tintOverride = TintOverrideGetter.get();
|
tintOverride,
|
||||||
tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper);
|
McObjectConverter.Convert(blockPos),
|
||||||
|
this.tintIndex);
|
||||||
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
|
|
||||||
if (tintColor == ClientBlockStateColorCache.INVALID_COLOR)
|
|
||||||
{
|
|
||||||
tintColor = Minecraft.getInstance()
|
|
||||||
.getBlockColors()
|
|
||||||
.getColor(this.blockState,
|
|
||||||
tintOverride,
|
|
||||||
McObjectConverter.Convert(blockPos),
|
|
||||||
this.tintIndex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -794,7 +645,7 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
|
|
||||||
int returnColor;
|
int returnColor;
|
||||||
if (tintColor != ClientBlockStateColorCache.INVALID_COLOR)
|
if (tintColor != AbstractDhTintGetter.INVALID_COLOR)
|
||||||
{
|
{
|
||||||
returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor);
|
returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor);
|
||||||
}
|
}
|
||||||
@@ -824,8 +675,6 @@ public class ClientBlockStateColorCache
|
|||||||
return returnColor;
|
return returnColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
@@ -843,54 +692,14 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
static EColorMode getColorMode(Block block)
|
static EColorMode getColorMode(Block block)
|
||||||
{
|
{
|
||||||
|
if (block instanceof LeavesBlock)
|
||||||
|
|
||||||
|
|
||||||
//========//
|
|
||||||
// leaves //
|
|
||||||
//========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isLeavesBlock;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isLeavesBlock = block instanceof BlockLeaves;
|
|
||||||
#else
|
|
||||||
isLeavesBlock = block instanceof LeavesBlock;
|
|
||||||
#endif
|
|
||||||
if (isLeavesBlock)
|
|
||||||
{
|
{
|
||||||
return Leaves;
|
return Leaves;
|
||||||
}
|
}
|
||||||
|
if (block instanceof FlowerBlock)
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//========//
|
|
||||||
// flower //
|
|
||||||
//========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
boolean isFlowerBlock;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
isFlowerBlock = block instanceof BlockFlower;
|
|
||||||
#else
|
|
||||||
isFlowerBlock = block instanceof FlowerBlock;
|
|
||||||
#endif
|
|
||||||
if (isFlowerBlock)
|
|
||||||
{
|
{
|
||||||
return Flower;
|
return Flower;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
|
||||||
// misc/simple //
|
|
||||||
//=============//
|
|
||||||
//region
|
|
||||||
|
|
||||||
if (block.toString().contains("glass"))
|
if (block.toString().contains("glass"))
|
||||||
{
|
{
|
||||||
return Glass;
|
return Glass;
|
||||||
@@ -899,11 +708,6 @@ public class ClientBlockStateColorCache
|
|||||||
{
|
{
|
||||||
return Chisel;
|
return Chisel;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Default;
|
return Default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -38,10 +38,7 @@ public class TextureAtlasSpriteWrapper
|
|||||||
{
|
{
|
||||||
public static int getPixelRGBA(TextureAtlasSprite sprite, int frameIndex, int x, int y)
|
public static int getPixelRGBA(TextureAtlasSprite sprite, int frameIndex, int x, int y)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
int[][] frameData = sprite.getFrameTextureData(frameIndex);
|
|
||||||
return frameData[0][y * sprite.getIconWidth() + x];
|
|
||||||
#elif MC_VER < MC_1_17_1
|
|
||||||
return sprite.mainImage[0].getPixelRGBA(
|
return sprite.mainImage[0].getPixelRGBA(
|
||||||
x + sprite.framesX[frameIndex] * sprite.getWidth(),
|
x + sprite.framesX[frameIndex] * sprite.getWidth(),
|
||||||
y + sprite.framesY[frameIndex] * sprite.getHeight());
|
y + sprite.framesY[frameIndex] * sprite.getHeight());
|
||||||
|
|||||||
+1
-2
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.block;
|
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.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -189,4 +189,3 @@ public class TintGetterOverride extends AbstractDhTintGetter
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+1
-2
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.block;
|
package com.seibel.distanthorizons.common.wrappers.block;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.LevelReader;
|
import net.minecraft.world.level.LevelReader;
|
||||||
@@ -109,4 +109,3 @@ public class TintWithoutLevelOverrider extends AbstractDhTintGetter
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+21
-143
@@ -31,19 +31,12 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
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.core.BlockPos;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
#endif
|
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
@@ -74,10 +67,9 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
|
|||||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_20_4
|
||||||
#elif MC_VER <= MC_1_20_4
|
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
#elif MC_VER > MC_1_12_2
|
#else
|
||||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -94,12 +86,8 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
private static boolean heightmapThreadWarningLogged = false;
|
private static boolean heightmapThreadWarningLogged = false;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final Chunk chunk;
|
|
||||||
#else
|
|
||||||
private final ChunkAccess chunk;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
private final ChunkAccess chunk;
|
||||||
private final DhChunkPos chunkPos;
|
private final DhChunkPos chunkPos;
|
||||||
private final ILevelWrapper wrappedLevel;
|
private final ILevelWrapper wrappedLevel;
|
||||||
|
|
||||||
@@ -124,17 +112,13 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
//region
|
|
||||||
/**
|
/**
|
||||||
* Note: this constructor should be very
|
* Note: this constructor should be very
|
||||||
* fast since it will be called frequently on the MC
|
* fast since it will be called frequently on the MC
|
||||||
* server thread and a slow method will cause server lag.
|
* server thread and a slow method will cause server lag.
|
||||||
*/
|
*/
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public ChunkWrapper(Chunk chunk, ILevelWrapper wrappedLevel)
|
|
||||||
#else
|
|
||||||
public ChunkWrapper(ChunkAccess chunk, ILevelWrapper wrappedLevel)
|
public ChunkWrapper(ChunkAccess chunk, ILevelWrapper wrappedLevel)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
this.chunk = chunk;
|
this.chunk = chunk;
|
||||||
this.wrappedLevel = wrappedLevel;
|
this.wrappedLevel = wrappedLevel;
|
||||||
@@ -149,22 +133,15 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
@Override
|
@Override
|
||||||
public ChunkWrapper copy() { return new ChunkWrapper(this.chunk, this.wrappedLevel); }
|
public ChunkWrapper copy() { return new ChunkWrapper(this.chunk, this.wrappedLevel); }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=========//
|
//=========//
|
||||||
// getters //
|
// getters //
|
||||||
//=========//
|
//=========//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight() { return getHeight(this.chunk); }
|
public int getHeight() { return getHeight(this.chunk); }
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static int getHeight(Chunk chunk)
|
|
||||||
#else
|
|
||||||
public static int getHeight(ChunkAccess chunk)
|
public static int getHeight(ChunkAccess chunk)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
return 255;
|
return 255;
|
||||||
@@ -175,11 +152,7 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInclusiveMinBuildHeight() { return getInclusiveMinBuildHeight(this.chunk); }
|
public int getInclusiveMinBuildHeight() { return getInclusiveMinBuildHeight(this.chunk); }
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static int getInclusiveMinBuildHeight(Chunk chunk)
|
|
||||||
#else
|
|
||||||
public static int getInclusiveMinBuildHeight(ChunkAccess chunk)
|
public static int getInclusiveMinBuildHeight(ChunkAccess chunk)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
return 0;
|
return 0;
|
||||||
@@ -192,15 +165,9 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getExclusiveMaxBuildHeight() { return getExclusiveMaxBuildHeight(this.chunk); }
|
public int getExclusiveMaxBuildHeight() { return getExclusiveMaxBuildHeight(this.chunk); }
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static int getExclusiveMaxBuildHeight(Chunk chunk)
|
|
||||||
#else
|
|
||||||
public static int getExclusiveMaxBuildHeight(ChunkAccess chunk)
|
public static int getExclusiveMaxBuildHeight(ChunkAccess chunk)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_3
|
||||||
return 256;
|
|
||||||
#elif MC_VER < MC_1_21_3
|
|
||||||
return chunk.getMaxBuildHeight();
|
return chunk.getMaxBuildHeight();
|
||||||
#else
|
#else
|
||||||
// +1 since Minecraft made the max value inclusive
|
// +1 since Minecraft made the max value inclusive
|
||||||
@@ -221,11 +188,7 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
this.minNonEmptyHeight = this.getInclusiveMinBuildHeight();
|
this.minNonEmptyHeight = this.getInclusiveMinBuildHeight();
|
||||||
|
|
||||||
// determine the lowest empty section (bottom up)
|
// 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();
|
LevelChunkSection[] sections = this.chunk.getSections();
|
||||||
#endif
|
|
||||||
for (int index = 0; index < sections.length; index++)
|
for (int index = 0; index < sections.length; index++)
|
||||||
{
|
{
|
||||||
if (sections[index] == null)
|
if (sections[index] == null)
|
||||||
@@ -257,11 +220,7 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
this.maxNonEmptyHeight = this.getExclusiveMaxBuildHeight();
|
this.maxNonEmptyHeight = this.getExclusiveMaxBuildHeight();
|
||||||
|
|
||||||
// determine the highest empty section (top down)
|
// 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();
|
LevelChunkSection[] sections = this.chunk.getSections();
|
||||||
#endif
|
|
||||||
for (int index = sections.length-1; index >= 0; index--)
|
for (int index = sections.length-1; index >= 0; index--)
|
||||||
{
|
{
|
||||||
// update at each position to fix using the max height if the chunk is empty
|
// update at each position to fix using the max height if the chunk is empty
|
||||||
@@ -281,13 +240,11 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
return this.maxNonEmptyHeight;
|
return this.maxNonEmptyHeight;
|
||||||
}
|
}
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static boolean isChunkSectionEmpty(ExtendedBlockStorage section)
|
|
||||||
#else
|
|
||||||
private static boolean isChunkSectionEmpty(LevelChunkSection section)
|
private static boolean isChunkSectionEmpty(LevelChunkSection section)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_17_1
|
#if MC_VER == MC_1_16_5
|
||||||
|
return section.isEmpty();
|
||||||
|
#elif MC_VER == MC_1_17_1
|
||||||
return section.isEmpty();
|
return section.isEmpty();
|
||||||
#else
|
#else
|
||||||
return section.hasOnlyAir();
|
return section.hasOnlyAir();
|
||||||
@@ -365,11 +322,7 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
// will be null if we want to use MC heightmaps
|
// will be null if we want to use MC heightmaps
|
||||||
if (this.solidHeightMap == null)
|
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);
|
return this.chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.WORLD_SURFACE).getFirstAvailable(xRel, zRel);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -384,11 +337,7 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
if (this.lightBlockingHeightMap == null)
|
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);
|
return this.chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.MOTION_BLOCKING).getFirstAvailable(xRel, zRel);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -400,14 +349,7 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
@Override
|
@Override
|
||||||
public IBiomeWrapper getBiome(int relX, int relY, int relZ)
|
public IBiomeWrapper getBiome(int relX, int relY, int relZ)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get();
|
|
||||||
blockPos.setPos(relX, relY, relZ);
|
|
||||||
|
|
||||||
World world = (World) this.wrappedLevel.getWrappedMcObject();
|
|
||||||
|
|
||||||
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiome(blockPos, world.getBiomeProvider()), wrappedLevel);
|
|
||||||
#elif MC_VER < MC_1_17_1
|
|
||||||
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome(
|
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome(
|
||||||
relX >> 2, relY >> 2, relZ >> 2),
|
relX >> 2, relY >> 2, relZ >> 2),
|
||||||
this.wrappedLevel);
|
this.wrappedLevel);
|
||||||
@@ -415,6 +357,10 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome(
|
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome(
|
||||||
QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ)),
|
QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ)),
|
||||||
this.wrappedLevel);
|
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
|
#else
|
||||||
//Now returns a Holder<Biome> instead of Biome
|
//Now returns a Holder<Biome> instead of Biome
|
||||||
return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome(
|
return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome(
|
||||||
@@ -430,13 +376,9 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
|
|
||||||
BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get();
|
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.setX(relX);
|
||||||
blockPos.setY(relY);
|
blockPos.setY(relY);
|
||||||
blockPos.setZ(relZ);
|
blockPos.setZ(relZ);
|
||||||
#endif
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -459,13 +401,9 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
|
this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
|
||||||
|
|
||||||
BlockPos.MutableBlockPos pos = (BlockPos.MutableBlockPos)mcBlockPos.getWrappedMcObject();
|
BlockPos.MutableBlockPos pos = (BlockPos.MutableBlockPos)mcBlockPos.getWrappedMcObject();
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
pos.setPos(relX, relY, relZ);
|
|
||||||
#else
|
|
||||||
pos.setX(relX);
|
pos.setX(relX);
|
||||||
pos.setY(relY);
|
pos.setY(relY);
|
||||||
pos.setZ(relZ);
|
pos.setZ(relZ);
|
||||||
#endif
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -575,14 +513,8 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
@Override
|
@Override
|
||||||
public DhChunkPos getChunkPos() { return this.chunkPos; }
|
public DhChunkPos getChunkPos() { return this.chunkPos; }
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
public ChunkAccess getChunk() { return this.chunk; }
|
||||||
public Chunk getChunk()
|
|
||||||
#else
|
|
||||||
public ChunkAccess getChunk()
|
|
||||||
#endif
|
|
||||||
{ return this.chunk; }
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public void trySetStatus(ChunkStatus status) { trySetStatus(this.getChunk(), status); }
|
public void trySetStatus(ChunkStatus status) { trySetStatus(this.getChunk(), status); }
|
||||||
/** does nothing if the chunk object doesn't support setting it's status */
|
/** does nothing if the chunk object doesn't support setting it's status */
|
||||||
public static void trySetStatus(ChunkAccess chunk, ChunkStatus status)
|
public static void trySetStatus(ChunkAccess chunk, ChunkStatus status)
|
||||||
@@ -606,53 +538,21 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
return chunk.getPersistedStatus();
|
return chunk.getPersistedStatus();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxBlockX()
|
public int getMaxBlockX() { return this.chunk.getPos().getMaxBlockX(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.chunk.getPos().getXEnd();
|
|
||||||
#else
|
|
||||||
return this.chunk.getPos().getMaxBlockX();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxBlockZ()
|
public int getMaxBlockZ() { return this.chunk.getPos().getMaxBlockZ(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.chunk.getPos().getZEnd();
|
|
||||||
#else
|
|
||||||
return this.chunk.getPos().getMaxBlockZ();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinBlockX()
|
public int getMinBlockX() { return this.chunk.getPos().getMinBlockX(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.chunk.getPos().getXStart();
|
|
||||||
#else
|
|
||||||
return this.chunk.getPos().getMinBlockX();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinBlockZ()
|
public int getMinBlockZ() { return this.chunk.getPos().getMinBlockZ(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.chunk.getPos().getZStart();
|
|
||||||
#else
|
|
||||||
return this.chunk.getPos().getMinBlockZ();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==========//
|
//==========//
|
||||||
// lighting //
|
// lighting //
|
||||||
//==========//
|
//==========//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIsDhSkyLightCorrect(boolean isDhLightCorrect) { this.isDhSkyLightCorrect = isDhLightCorrect; }
|
public void setIsDhSkyLightCorrect(boolean isDhLightCorrect) { this.isDhSkyLightCorrect = isDhLightCorrect; }
|
||||||
@@ -729,23 +629,8 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
{
|
{
|
||||||
this.blockLightPosList = new ArrayList<>();
|
this.blockLightPosList = new ArrayList<>();
|
||||||
|
|
||||||
//1.12.2 doesn't store lights we must bruteforce it
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
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.chunk.getLights().forEach((blockPos) ->
|
||||||
{
|
{
|
||||||
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||||
@@ -767,14 +652,11 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
return this.blockLightPosList;
|
return this.blockLightPosList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// base overrides //
|
// base overrides //
|
||||||
//================//
|
//================//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return this.chunk.getClass().getSimpleName() + this.chunk.getPos(); }
|
public String toString() { return this.chunk.getClass().getSimpleName() + this.chunk.getPos(); }
|
||||||
@@ -790,8 +672,4 @@ public class ChunkWrapper implements IChunkWrapper
|
|||||||
// return this.blockBiomeHashCode;
|
// return this.blockBiomeHashCode;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui;
|
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;
|
import net.minecraft.client.gui.Font;
|
||||||
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
@@ -23,73 +16,26 @@ import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public class DhScreen extends GuiScreen
|
|
||||||
#else
|
|
||||||
public class DhScreen extends Screen
|
public class DhScreen extends Screen
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
protected ITextComponent title;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
protected DhScreen(Component $$0)
|
||||||
protected DhScreen(ITextComponent title)
|
|
||||||
{
|
{
|
||||||
this.title = title;
|
super($$0);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
protected DhScreen(Component title)
|
|
||||||
{
|
|
||||||
super(title);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// addRenderableWidget in 1.17 and over
|
// addRenderableWidget in 1.17 and over
|
||||||
// addButton in 1.16 and below
|
// addButton in 1.16 and below
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
protected GuiButton addBtn(GuiButton button)
|
|
||||||
#else
|
|
||||||
protected Button addBtn(Button button)
|
protected Button addBtn(Button button)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
this.buttonList.add(button);
|
|
||||||
return button;
|
|
||||||
#elif MC_VER < MC_1_17_1
|
|
||||||
return this.addButton(button);
|
return this.addButton(button);
|
||||||
#else
|
#else
|
||||||
return this.addRenderableWidget(button);
|
return this.addRenderableWidget(button);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
@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<ITextComponent> 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)
|
protected void DhDrawCenteredString(PoseStack guiStack, Font font, Component text, int x, int y, int color)
|
||||||
{
|
{
|
||||||
drawCenteredString(guiStack, font, text, x, y, color);
|
drawCenteredString(guiStack, font, text, x, y, color);
|
||||||
@@ -166,4 +112,7 @@ public class DhScreen extends Screen
|
|||||||
guiStack.setTooltipForNextFrame(font, text, x, y);
|
guiStack.setTooltipForNextFrame(font, text, x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.seibel.distanthorizons.common.wrappers.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class DhScreenUtil
|
||||||
|
{
|
||||||
|
//================//
|
||||||
|
// helper methods //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public static void showScreen(Screen screen)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
Objects.requireNonNull(Minecraft.getInstance()).setScreen(screen);
|
||||||
|
#else
|
||||||
|
Objects.requireNonNull(Minecraft.getInstance()).setScreenAndShow(screen);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
-8
@@ -4,22 +4,14 @@ import com.seibel.distanthorizons.common.wrappers.gui.classicConfig.ClassicConfi
|
|||||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
public class GetConfigScreen
|
public class GetConfigScreen
|
||||||
{
|
{
|
||||||
protected static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
protected static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static GuiScreen getScreen(GuiScreen parent)
|
|
||||||
#else
|
|
||||||
public static Screen getScreen(Screen parent)
|
public static Screen getScreen(Screen parent)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (ModInfo.IS_DEV_BUILD)
|
if (ModInfo.IS_DEV_BUILD)
|
||||||
{
|
{
|
||||||
|
|||||||
+11
-63
@@ -1,21 +1,11 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui;
|
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.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
#endif
|
#endif
|
||||||
@@ -25,99 +15,57 @@ public class GuiHelper
|
|||||||
/**
|
/**
|
||||||
* Helper static methods for versional compat
|
* Helper static methods for versional compat
|
||||||
*/
|
*/
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static final Map<GuiButton, OnPressed> HANDLER_BY_BUTTON = new HashMap<>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static GuiButton MakeBtn(ITextComponent base, int posX, int posZ, int width, int height, OnPressed action)
|
|
||||||
#else
|
|
||||||
public static Button MakeBtn(Component base, int posX, int posZ, int width, int height, Button.OnPress action)
|
public static Button MakeBtn(Component base, int posX, int posZ, int width, int height, Button.OnPress action)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_4
|
||||||
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);
|
return new Button(posX, posZ, width, height, base, action);
|
||||||
#else
|
#else
|
||||||
return Button.builder(base, action).bounds(posX, posZ, width, height).build();
|
return Button.builder(base, action).bounds(posX, posZ, width, height).build();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static ITextComponent TextOrLiteral(String text)
|
|
||||||
#else
|
|
||||||
public static MutableComponent TextOrLiteral(String text)
|
public static MutableComponent TextOrLiteral(String text)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
return new TextComponentString(text);
|
|
||||||
#elif MC_VER < MC_1_19_2
|
|
||||||
return new TextComponent(text);
|
return new TextComponent(text);
|
||||||
#else
|
#else
|
||||||
return Component.literal(text);
|
return Component.literal(text);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static ITextComponent TextOrTranslatable(String text)
|
|
||||||
#else
|
|
||||||
public static MutableComponent TextOrTranslatable(String text)
|
public static MutableComponent TextOrTranslatable(String text)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
return new TextComponentString(text);
|
|
||||||
#elif MC_VER < MC_1_19_2
|
|
||||||
return new TextComponent(text);
|
return new TextComponent(text);
|
||||||
#else
|
#else
|
||||||
return Component.translatable(text);
|
return Component.translatable(text);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static ITextComponent Translatable(String text, Object... args)
|
|
||||||
#else
|
|
||||||
public static MutableComponent Translatable(String text, Object... args)
|
public static MutableComponent Translatable(String text, Object... args)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
return new TextComponentTranslation(text, args);
|
|
||||||
#elif MC_VER < MC_1_19_2
|
|
||||||
return new TranslatableComponent(text, args);
|
return new TranslatableComponent(text, args);
|
||||||
#else
|
#else
|
||||||
return Component.translatable(text, args);
|
return Component.translatable(text, args);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
public static void SetX(AbstractWidget w, int x)
|
||||||
public static void SetX(GuiButton widget, int x)
|
|
||||||
#else
|
|
||||||
public static void SetX(AbstractWidget widget, int x)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_19_4
|
#if MC_VER < MC_1_19_4
|
||||||
widget.x = x;
|
w.x = x;
|
||||||
#else
|
#else
|
||||||
widget.setX(x);
|
w.setX(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
public static void SetY(AbstractWidget w, int y)
|
||||||
public static void SetY(GuiTextField textField, int y) { textField.y = y; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static void SetY(GuiButton widget, int y)
|
|
||||||
#else
|
|
||||||
public static void SetY(AbstractWidget widget, int y)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_19_4
|
#if MC_VER < MC_1_19_4
|
||||||
widget.y = y;
|
w.y = y;
|
||||||
#else
|
#else
|
||||||
widget.setY(y);
|
w.setY(y);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,21 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui;
|
package com.seibel.distanthorizons.common.wrappers.gui;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
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;
|
import net.minecraft.client.resources.language.I18n;
|
||||||
#endif
|
|
||||||
|
|
||||||
public class LangWrapper implements ILangWrapper
|
public class LangWrapper implements ILangWrapper
|
||||||
{
|
{
|
||||||
public static final LangWrapper INSTANCE = new LangWrapper();
|
public static final LangWrapper INSTANCE = new LangWrapper();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean langExists(String str)
|
public boolean langExists(String str)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return I18n.hasKey(str);
|
|
||||||
#else
|
|
||||||
return I18n.exists(str);
|
return I18n.exists(str);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLang(String str)
|
public String getLang(String str)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return I18n.format(str);
|
|
||||||
#else
|
|
||||||
return I18n.get(str);
|
return I18n.get(str);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-120
@@ -1,27 +1,17 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui;
|
package com.seibel.distanthorizons.common.wrappers.gui;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import org.lwjglx.opengl.Display;
|
|
||||||
#else
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
#endif
|
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.config.gui.AbstractScreen;
|
import com.seibel.distanthorizons.core.config.gui.AbstractScreen;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
#endif
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
import net.minecraft.client.gui.GuiListExtended;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.gui.GuiSlot;
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
@@ -34,29 +24,28 @@ import java.util.*;
|
|||||||
|
|
||||||
public class MinecraftScreen
|
public class MinecraftScreen
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
//
|
||||||
public static GuiScreen getScreen(GuiScreen parent, AbstractScreen screen, String translationName)
|
// helper methods
|
||||||
#else
|
//
|
||||||
|
|
||||||
public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName)
|
public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName)
|
||||||
#endif
|
{ return new ConfigScreenRenderer(parent, screen, translationName); }
|
||||||
{
|
|
||||||
return new ConfigScreenRenderer(parent, screen, translationName);
|
|
||||||
}
|
|
||||||
|
//=========//
|
||||||
|
// screens //
|
||||||
|
//=========//
|
||||||
|
//region
|
||||||
|
|
||||||
private static class ConfigScreenRenderer extends DhScreen
|
private static class ConfigScreenRenderer extends DhScreen
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final GuiScreen parent;
|
|
||||||
#else
|
|
||||||
private final Screen parent;
|
private final Screen parent;
|
||||||
#endif
|
|
||||||
private ConfigListWidget configListWidget;
|
private ConfigListWidget configListWidget;
|
||||||
private AbstractScreen screen;
|
private AbstractScreen screen;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static net.minecraft.util.text.TextComponentTranslation translate(String str, Object... args)
|
#if MC_VER < MC_1_19_2
|
||||||
{ 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)
|
public static net.minecraft.network.chat.TranslatableComponent translate(String str, Object... args)
|
||||||
{ return new net.minecraft.network.chat.TranslatableComponent(str, args); }
|
{ return new net.minecraft.network.chat.TranslatableComponent(str, args); }
|
||||||
#else
|
#else
|
||||||
@@ -64,16 +53,10 @@ public class MinecraftScreen
|
|||||||
{ return net.minecraft.network.chat.Component.translatable(str, args); }
|
{ return net.minecraft.network.chat.Component.translatable(str, args); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
protected ConfigScreenRenderer(GuiScreen parent, AbstractScreen screen, String translationName)
|
|
||||||
#else
|
|
||||||
protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName)
|
protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
super(translate(translationName));
|
super(translate(translationName));
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_9
|
||||||
screen.minecraftWindow = Display.getWindow();
|
|
||||||
#elif MC_VER < MC_1_21_9
|
|
||||||
screen.minecraftWindow = Minecraft.getInstance().getWindow().getWindow();
|
screen.minecraftWindow = Minecraft.getInstance().getWindow().getWindow();
|
||||||
#else
|
#else
|
||||||
screen.minecraftWindow = Minecraft.getInstance().getWindow().handle();
|
screen.minecraftWindow = Minecraft.getInstance().getWindow().handle();
|
||||||
@@ -83,53 +66,30 @@ public class MinecraftScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void initGui()
|
|
||||||
#else
|
|
||||||
protected void init()
|
protected void init()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
super.init(); // Init Minecraft's screen
|
||||||
super.initGui();
|
|
||||||
#else
|
|
||||||
super.init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.screen.width = Display.getWidth();
|
|
||||||
this.screen.height = Display.getHeight();
|
|
||||||
#else
|
|
||||||
Window mcWindow = this.minecraft.getWindow();
|
Window mcWindow = this.minecraft.getWindow();
|
||||||
this.screen.width = mcWindow.getWidth();
|
this.screen.width = mcWindow.getWidth();
|
||||||
this.screen.height = mcWindow.getHeight();
|
this.screen.height = mcWindow.getHeight();
|
||||||
#endif
|
|
||||||
this.screen.scaledWidth = this.width;
|
this.screen.scaledWidth = this.width;
|
||||||
this.screen.scaledHeight = this.height;
|
this.screen.scaledHeight = this.height;
|
||||||
this.screen.init(); // Init our own config screen
|
this.screen.init(); // Init our own config screen
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.configListWidget = new ConfigListWidget(this.mc, this.width, this.height, 0, 0, 25); // Select the area to tint
|
|
||||||
#else
|
|
||||||
this.configListWidget = new ConfigListWidget(this.minecraft, this.width, this.height, 0, 0, 25); // Select the area to tint
|
this.configListWidget = new ConfigListWidget(this.minecraft, this.width, this.height, 0, 0, 25); // Select the area to tint
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||||
#elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
|
||||||
if (this.minecraft != null && this.minecraft.level != null) // Check if in game
|
if (this.minecraft != null && this.minecraft.level != null) // Check if in game
|
||||||
{
|
{
|
||||||
this.configListWidget.setRenderBackground(false); // Disable from rendering
|
this.configListWidget.setRenderBackground(false); // Disable from rendering
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.addWidget(this.configListWidget); // Add the tint to the things to be rendered
|
this.addWidget(this.configListWidget); // Add the tint to the things to be rendered
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
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)
|
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
@@ -137,9 +97,7 @@ public class MinecraftScreen
|
|||||||
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_2
|
||||||
this.drawDefaultBackground();
|
|
||||||
#elif MC_VER < MC_1_20_2
|
|
||||||
this.renderBackground(matrices); // Render background
|
this.renderBackground(matrices); // Render background
|
||||||
#elif MC_VER < MC_1_21_6
|
#elif MC_VER < MC_1_21_6
|
||||||
this.renderBackground(matrices, mouseX, mouseY, delta); // Render background
|
this.renderBackground(matrices, mouseX, mouseY, delta); // Render background
|
||||||
@@ -147,9 +105,7 @@ public class MinecraftScreen
|
|||||||
// background blur is already being rendered, rendering again causes the game to crash
|
// background blur is already being rendered, rendering again causes the game to crash
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
this.configListWidget.drawScreen(mouseX, mouseY, delta);
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
this.configListWidget.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
|
this.configListWidget.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
|
||||||
#else
|
#else
|
||||||
this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
|
this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
|
||||||
@@ -159,86 +115,55 @@ public class MinecraftScreen
|
|||||||
this.screen.mouseY = mouseY;
|
this.screen.mouseY = mouseY;
|
||||||
this.screen.render(delta); // Render everything on the main screen
|
this.screen.render(delta); // Render everything on the main screen
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
super.drawScreen(mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint)
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint)
|
super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint)
|
||||||
#else
|
#else
|
||||||
super.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
|
super.extractRenderState(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void setWorldAndResolution(Minecraft mc, int width, int height)
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
public void resize(Minecraft mc, int width, int height)
|
public void resize(Minecraft mc, int width, int height)
|
||||||
#else
|
#else
|
||||||
|
@Override
|
||||||
public void resize(int width, int height)
|
public void resize(int width, int height)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Resize Minecraft's screen
|
// Resize Minecraft's screen
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
super.setWorldAndResolution(mc, width, height);
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
super.resize(mc, width, height);
|
super.resize(mc, width, height);
|
||||||
#else
|
#else
|
||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.screen.width = Display.getWidth();
|
|
||||||
this.screen.height = Display.getHeight();
|
|
||||||
#else
|
|
||||||
Window mcWindow = this.minecraft.getWindow();
|
Window mcWindow = this.minecraft.getWindow();
|
||||||
this.screen.width = mcWindow.getWidth();
|
this.screen.width = mcWindow.getWidth();
|
||||||
this.screen.height = mcWindow.getHeight();
|
this.screen.height = mcWindow.getHeight();
|
||||||
#endif;
|
|
||||||
this.screen.scaledWidth = this.width;
|
this.screen.scaledWidth = this.width;
|
||||||
this.screen.scaledHeight = this.height;
|
this.screen.scaledHeight = this.height;
|
||||||
this.screen.onResize(); // Resize our screen
|
this.screen.onResize(); // Resize our screen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void updateScreen()
|
|
||||||
#else
|
|
||||||
public void tick()
|
public void tick()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
super.updateScreen(); // Tick Minecraft's screen
|
|
||||||
#else
|
|
||||||
super.tick(); // Tick Minecraft's screen
|
super.tick(); // Tick Minecraft's screen
|
||||||
#endif
|
|
||||||
|
|
||||||
this.screen.tick(); // Tick our screen
|
this.screen.tick(); // Tick our screen
|
||||||
if (this.screen.close) // If we decide to close the screen, then actually close the 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();
|
this.onClose();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void onGuiClosed()
|
|
||||||
#else
|
|
||||||
public void onClose()
|
public void onClose()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
this.screen.onClose(); // Close our screen
|
this.screen.onClose(); // Close our screen
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.showScreen(this.parent); // Goto the parent screen
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); // Goto the parent screen
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
@Override
|
@Override
|
||||||
public void onFilesDrop(@NotNull List<Path> files)
|
public void onFilesDrop(@NotNull List<Path> files)
|
||||||
{ this.screen.onFilesDrop(files); }
|
{ this.screen.onFilesDrop(files); }
|
||||||
@@ -247,14 +172,10 @@ public class MinecraftScreen
|
|||||||
@Override
|
@Override
|
||||||
public boolean shouldCloseOnEsc()
|
public boolean shouldCloseOnEsc()
|
||||||
{ return this.screen.shouldCloseOnEsc; }
|
{ return this.screen.shouldCloseOnEsc; }
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static class ConfigListWidget extends GuiListExtended
|
|
||||||
#else
|
|
||||||
public static class ConfigListWidget extends ContainerObjectSelectionList
|
public static class ConfigListWidget extends ContainerObjectSelectionList
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
||||||
{
|
{
|
||||||
@@ -266,18 +187,10 @@ public class MinecraftScreen
|
|||||||
this.centerListVertically = false;
|
this.centerListVertically = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
@Override
|
|
||||||
protected int getSize()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public IGuiListEntry getListEntry(int index)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
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
|
|
||||||
+22
-66
@@ -19,21 +19,13 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.gui;
|
package com.seibel.distanthorizons.common.wrappers.gui;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER >= MC_1_17_1
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
#endif
|
#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 net.minecraft.client.gui.components.ImageButton;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
@@ -61,9 +53,7 @@ import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|||||||
import net.minecraft.client.renderer.RenderPipelines;
|
import net.minecraft.client.renderer.RenderPipelines;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
@@ -75,10 +65,7 @@ import net.minecraft.resources.Identifier;
|
|||||||
* @author coolGi
|
* @author coolGi
|
||||||
* @version 2023-10-03
|
* @version 2023-10-03
|
||||||
*/
|
*/
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_2
|
||||||
@SuppressWarnings("deprecation") // we use a few deprecated Mojang functions (as expected when running on old MC versions)
|
|
||||||
public class TexturedButtonWidget extends GuiButton
|
|
||||||
#elif MC_VER < MC_1_20_2
|
|
||||||
@SuppressWarnings("deprecation") // we use a few deprecated Mojang functions (as expected when running on old MC versions)
|
@SuppressWarnings("deprecation") // we use a few deprecated Mojang functions (as expected when running on old MC versions)
|
||||||
public class TexturedButtonWidget extends ImageButton
|
public class TexturedButtonWidget extends ImageButton
|
||||||
#else
|
#else
|
||||||
@@ -88,7 +75,7 @@ public class TexturedButtonWidget extends Button
|
|||||||
{
|
{
|
||||||
public final boolean renderBackground;
|
public final boolean renderBackground;
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_2 || MC_VER <= MC_1_12_2
|
#if MC_VER >= MC_1_20_2
|
||||||
private final int u;
|
private final int u;
|
||||||
private final int v;
|
private final int v;
|
||||||
private final int hoveredVOffset;
|
private final int hoveredVOffset;
|
||||||
@@ -103,41 +90,30 @@ public class TexturedButtonWidget extends Button
|
|||||||
private final int textureHeight;
|
private final int textureHeight;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public TexturedButtonWidget(int id, int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, String text)
|
|
||||||
{
|
|
||||||
this(id, x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, text, true);
|
|
||||||
}
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text)
|
|
||||||
{
|
|
||||||
this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text)
|
|
||||||
{
|
|
||||||
this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
public TexturedButtonWidget(
|
||||||
public TexturedButtonWidget(int id, int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, String text, boolean renderBackground)
|
int x, int y, int width, int height, int u, int v, int hoveredVOffset,
|
||||||
#elif MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation,
|
||||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text, boolean renderBackground)
|
#else Identifier textureResourceLocation,
|
||||||
#else
|
#endif
|
||||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text, boolean renderBackground)
|
int textureWidth, int textureHeight, OnPress pressAction, Component text)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true);
|
||||||
super(id, x, y, width, height, text);
|
}
|
||||||
#elif MC_VER < MC_1_20_2
|
public TexturedButtonWidget(
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
#if MC_VER < MC_1_20_2
|
||||||
super(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text);
|
super(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text);
|
||||||
#else
|
#else
|
||||||
// We don't pass in the text option since it will render (we normally pass it in for narration)
|
// 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);
|
super(x, y, width, height, Component.empty(), pressAction, DEFAULT_NARRATION);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_2 || MC_VER <= MC_1_12_2
|
|
||||||
this.u = u;
|
this.u = u;
|
||||||
this.v = v;
|
this.v = v;
|
||||||
this.hoveredVOffset = hoveredVOffset;
|
this.hoveredVOffset = hoveredVOffset;
|
||||||
@@ -151,27 +127,7 @@ public class TexturedButtonWidget extends Button
|
|||||||
this.renderBackground = renderBackground;
|
this.renderBackground = renderBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_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
|
#if MC_VER < MC_1_19_4
|
||||||
@Override
|
@Override
|
||||||
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta)
|
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
|
|||||||
+49
-246
@@ -12,24 +12,17 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosi
|
|||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.client.gui.*;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#elif MC_VER < MC_1_20_1
|
#if MC_VER < MC_1_20_1
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
@@ -74,7 +67,6 @@ public class ClassicConfigGUI
|
|||||||
//==============//
|
//==============//
|
||||||
// Initializers //
|
// Initializers //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
|
||||||
|
|
||||||
// Some regexes to check if an input is valid
|
// Some regexes to check if an input is valid
|
||||||
public static final Pattern INTEGER_ONLY_REGEX = Pattern.compile("(-?[0-9]*)");
|
public static final Pattern INTEGER_ONLY_REGEX = Pattern.compile("(-?[0-9]*)");
|
||||||
@@ -95,46 +87,25 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
// GUI handling //
|
// GUI handling //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
|
||||||
/** if you want to get this config gui's screen call this */
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static GuiScreen getScreen(GuiScreen parent, String category)
|
|
||||||
#else
|
|
||||||
public static Screen getScreen(Screen parent, String category)
|
|
||||||
#endif
|
|
||||||
{ return new DhConfigScreen(parent, category); }
|
|
||||||
|
|
||||||
//endregion
|
/** if you want to get this config gui's screen call this */
|
||||||
|
public static Screen getScreen(Screen parent, String category)
|
||||||
|
{ return new DhConfigScreen(parent, category); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// helper classes //
|
// helper classes //
|
||||||
//================//
|
//================//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static class ConfigListWidget extends GuiListExtended
|
|
||||||
#else
|
|
||||||
public static class ConfigListWidget extends ContainerObjectSelectionList<DhButtonEntry>
|
public static class ConfigListWidget extends ContainerObjectSelectionList<DhButtonEntry>
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public List<DhButtonEntry> children = new ArrayList<>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
FontRenderer textRenderer;
|
|
||||||
#else
|
|
||||||
Font textRenderer;
|
Font textRenderer;
|
||||||
#endif
|
|
||||||
|
|
||||||
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
||||||
{
|
{
|
||||||
@@ -145,121 +116,40 @@ public class ClassicConfigGUI
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
this.centerListVertically = false;
|
this.centerListVertically = false;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.textRenderer = minecraftClient.fontRenderer;
|
|
||||||
#else
|
|
||||||
this.textRenderer = minecraftClient.font;
|
this.textRenderer = minecraftClient.font;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
@Override
|
|
||||||
protected int getSize()
|
|
||||||
{
|
|
||||||
return this.children.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IGuiListEntry getListEntry(int index)
|
|
||||||
{
|
|
||||||
return this.children.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawContainerBackground(Tessellator tessellator)
|
|
||||||
{
|
|
||||||
if (this.mc.world != null)
|
|
||||||
{
|
|
||||||
return; // in-game don't draw dirt background
|
|
||||||
}
|
|
||||||
super.drawContainerBackground(tessellator);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, GuiButton resetButton, GuiButton indexButton, ITextComponent text)
|
|
||||||
#else
|
|
||||||
public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, AbstractWidget resetButton, AbstractWidget indexButton, Component text)
|
public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, AbstractWidget resetButton, AbstractWidget indexButton, Component text)
|
||||||
#endif
|
{ this.addEntry(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.children.add(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton));
|
|
||||||
#else
|
|
||||||
this.addEntry(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
public int getRowWidth() { return 10_000; }
|
||||||
public int getListWidth()
|
|
||||||
#else
|
|
||||||
public int getRowWidth()
|
|
||||||
#endif
|
|
||||||
{ return 10_000; }
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public Gui getHoveredButton(double mouseX, double mouseY)
|
|
||||||
#else
|
|
||||||
public AbstractWidget getHoveredButton(double mouseX, double mouseY)
|
public AbstractWidget getHoveredButton(double mouseX, double mouseY)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
for (DhButtonEntry buttonEntry : this.children)
|
|
||||||
#else
|
|
||||||
for (DhButtonEntry buttonEntry : this.children())
|
for (DhButtonEntry buttonEntry : this.children())
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
AbstractWidget button = buttonEntry.button;
|
||||||
Gui gui = buttonEntry.button;
|
if (button != null
|
||||||
if (gui == null) continue;
|
&& button.visible)
|
||||||
|
|
||||||
double minX, minY, maxX, maxY;
|
|
||||||
|
|
||||||
if (gui instanceof GuiButton button)
|
|
||||||
{
|
{
|
||||||
if (!button.visible) continue;
|
#if MC_VER < MC_1_19_4
|
||||||
minX = button.x;
|
double minX = button.x;
|
||||||
minY = button.y;
|
double minY = button.y;
|
||||||
maxX = minX + button.width;
|
#else
|
||||||
maxY = minY + button.height;
|
double minX = button.getX();
|
||||||
}
|
double minY = button.getY();
|
||||||
else if (gui instanceof GuiTextField field)
|
#endif
|
||||||
{
|
|
||||||
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)
|
double maxX = minX + button.getWidth();
|
||||||
{
|
double maxY = minY + button.getHeight();
|
||||||
return gui;
|
|
||||||
|
if (mouseX >= minX && mouseX < maxX
|
||||||
|
&& mouseY >= minY && mouseY < maxY)
|
||||||
|
{
|
||||||
|
return button;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#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;
|
return null;
|
||||||
@@ -267,60 +157,32 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static class DhButtonEntry implements GuiListExtended.IGuiListEntry
|
|
||||||
#else
|
|
||||||
public static class DhButtonEntry extends ContainerObjectSelectionList.Entry<DhButtonEntry>
|
public static class DhButtonEntry extends ContainerObjectSelectionList.Entry<DhButtonEntry>
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final FontRenderer textRenderer = Minecraft.getMinecraft().fontRenderer;
|
|
||||||
#else
|
|
||||||
private static final Font textRenderer = Minecraft.getInstance().font;
|
private static final Font textRenderer = Minecraft.getInstance().font;
|
||||||
#endif
|
|
||||||
|
private final AbstractWidget button;
|
||||||
|
|
||||||
private final DhConfigScreen gui;
|
private final DhConfigScreen gui;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public final Gui button;
|
|
||||||
public final Gui resetButton;
|
|
||||||
public final Gui indexButton;
|
|
||||||
#else
|
|
||||||
private final AbstractWidget indexButton;
|
|
||||||
private final AbstractWidget resetButton;
|
private final AbstractWidget resetButton;
|
||||||
private final AbstractWidget button;
|
private final AbstractWidget indexButton;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final ITextComponent text;
|
|
||||||
#else
|
|
||||||
private final Component text;
|
private final Component text;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final List<Gui> children = new ArrayList<>();
|
|
||||||
#else
|
|
||||||
private final List<AbstractWidget> children = new ArrayList<>();
|
private final List<AbstractWidget> children = new ArrayList<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final EConfigCommentTextPosition textPosition;
|
private final EConfigCommentTextPosition textPosition;
|
||||||
public final AbstractConfigBase dhConfigType;
|
public final AbstractConfigBase dhConfigType;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static final Map<Gui, ITextComponent> TEXT_BY_WIDGET = new HashMap<>();
|
|
||||||
public static final Map<Gui, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
|
|
||||||
#else
|
|
||||||
public static final Map<AbstractWidget, Component> TEXT_BY_WIDGET = new HashMap<>();
|
public static final Map<AbstractWidget, Component> TEXT_BY_WIDGET = new HashMap<>();
|
||||||
public static final Map<AbstractWidget, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
|
public static final Map<AbstractWidget, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
public DhButtonEntry(
|
||||||
public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, ITextComponent text, GuiButton resetButton, GuiButton indexButton)
|
DhConfigScreen gui, AbstractConfigBase dhConfigType,
|
||||||
#else
|
AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton)
|
||||||
public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
TEXT_BY_WIDGET.put(button, text);
|
TEXT_BY_WIDGET.put(button, text);
|
||||||
BUTTON_BY_WIDGET.put(button, this);
|
BUTTON_BY_WIDGET.put(button, this);
|
||||||
@@ -363,9 +225,7 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float tickDelta)
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
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
|
#elif MC_VER < MC_1_21_9
|
||||||
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
||||||
@@ -390,40 +250,18 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
if (this.button != null)
|
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);
|
SetY(this.button, y);
|
||||||
{
|
#if MC_VER <= MC_1_21_11
|
||||||
#if MC_VER <= MC_1_21_11
|
this.button.render(matrices, mouseX, mouseY, tickDelta);
|
||||||
this.button.render(matrices, mouseX, mouseY, tickDelta);
|
#else
|
||||||
#else
|
this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||||
this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.resetButton != null)
|
if (this.resetButton != null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
SetY((GuiButton) this.resetButton, y);
|
|
||||||
#else
|
|
||||||
SetY(this.resetButton, y);
|
SetY(this.resetButton, y);
|
||||||
#endif
|
#if MC_VER <= MC_1_21_11
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
this.resetButton.render(matrices, mouseX, mouseY, tickDelta);
|
this.resetButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||||
#else
|
#else
|
||||||
this.resetButton.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
this.resetButton.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||||
@@ -432,15 +270,8 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
if (this.indexButton != null)
|
if (this.indexButton != null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
SetY((GuiButton) this.indexButton, y);
|
|
||||||
#else
|
|
||||||
SetY(this.indexButton, y);
|
SetY(this.indexButton, y);
|
||||||
#endif
|
#if MC_VER <= MC_1_21_11
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
((GuiButton) this.indexButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
this.indexButton.render(matrices, mouseX, mouseY, tickDelta);
|
this.indexButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||||
#else
|
#else
|
||||||
this.indexButton.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
this.indexButton.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||||
@@ -449,11 +280,7 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
if (this.text != null)
|
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);
|
int translatedLength = textRenderer.width(this.text);
|
||||||
#endif
|
|
||||||
|
|
||||||
int textXPos;
|
int textXPos;
|
||||||
if (this.textPosition == EConfigCommentTextPosition.RIGHT_JUSTIFIED)
|
if (this.textPosition == EConfigCommentTextPosition.RIGHT_JUSTIFIED)
|
||||||
@@ -486,21 +313,17 @@ public class ClassicConfigGUI
|
|||||||
throw new UnsupportedOperationException("No text position render defined for [" + this.textPosition + "]");
|
throw new UnsupportedOperationException("No text position render defined for [" + this.textPosition + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
textRenderer.drawString(
|
#if MC_VER < MC_1_20_1
|
||||||
this.text.getFormattedText(),
|
|
||||||
textXPos, y + 5,
|
|
||||||
0xFFFFFF);
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
GuiComponent.drawString(matrices, textRenderer,
|
GuiComponent.drawString(matrices, textRenderer,
|
||||||
this.text,
|
this.text,
|
||||||
textXPos, y + 5,
|
textXPos, y + 5,
|
||||||
0xFFFFFF);
|
0xFFFFFF);
|
||||||
#elif MC_VER < MC_1_21_6
|
#elif MC_VER < MC_1_21_6
|
||||||
matrices.drawString(textRenderer,
|
matrices.drawString(textRenderer,
|
||||||
this.text,
|
this.text,
|
||||||
textXPos, y + 5,
|
textXPos, y + 5,
|
||||||
0xFFFFFF);
|
0xFFFFFF);
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
matrices.drawString(textRenderer,
|
matrices.drawString(textRenderer,
|
||||||
this.text,
|
this.text,
|
||||||
@@ -521,25 +344,9 @@ public class ClassicConfigGUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
@Override
|
|
||||||
public void updatePosition(int slotIndex, int x, int y, float partialTicks) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY)
|
|
||||||
{
|
|
||||||
return false; // handled in DhConfigScreen.mouseClicked
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) { }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<? extends GuiEventListener> children()
|
public @NotNull List<? extends GuiEventListener> children()
|
||||||
{ return this.children; }
|
{ return this.children; }
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER >= MC_1_17_1
|
||||||
@Override
|
@Override
|
||||||
@@ -551,14 +358,11 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// event handling //
|
// event handling //
|
||||||
//================//
|
//================//
|
||||||
//region
|
|
||||||
|
|
||||||
public static class ConfigCoreInterface implements IConfigGui
|
public static class ConfigCoreInterface implements IConfigGui
|
||||||
{
|
{
|
||||||
@@ -577,5 +381,4 @@ public class ClassicConfigGUI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
}
|
}
|
||||||
|
|||||||
+62
-371
@@ -3,61 +3,41 @@ package com.seibel.distanthorizons.common.wrappers.gui.classicConfig;
|
|||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui;
|
import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.GuiHelper;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.config.ConfigGuiInfo;
|
import com.seibel.distanthorizons.common.wrappers.gui.config.ConfigGuiInfo;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||||
import com.seibel.distanthorizons.core.config.types.*;
|
import com.seibel.distanthorizons.core.config.types.*;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.OnPressed;
|
|
||||||
#else
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition;
|
|
||||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity;
|
import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.AnnotationUtil;
|
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.core.wrapperInterfaces.config.ILangWrapper;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.client.gui.*;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.Style;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
#else
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#elif MC_VER < MC_1_20_1
|
#if MC_VER < MC_1_20_1
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
@@ -67,21 +47,16 @@ import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER >= MC_1_17_1
|
||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
#endif
|
|
||||||
|
|
||||||
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
||||||
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable;
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable;
|
||||||
@@ -95,21 +70,13 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE;
|
private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final GuiScreen parent;
|
|
||||||
#else
|
|
||||||
private final Screen parent;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
private final Screen parent;
|
||||||
private final String category;
|
private final String category;
|
||||||
private ClassicConfigGUI.ConfigListWidget configListWidget;
|
private ClassicConfigGUI.ConfigListWidget configListWidget;
|
||||||
private boolean reload = false;
|
private boolean reload = false;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private GuiButton doneButton;
|
|
||||||
#else
|
|
||||||
private Button doneButton;
|
private Button doneButton;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -118,11 +85,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
//=============//
|
//=============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
protected DhConfigScreen(GuiScreen parent, String category)
|
|
||||||
#else
|
|
||||||
protected DhConfigScreen(Screen parent, String category)
|
protected DhConfigScreen(Screen parent, String category)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
super(Translatable(
|
super(Translatable(
|
||||||
LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
|
LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
|
||||||
@@ -136,18 +99,13 @@ class DhConfigScreen extends DhScreen
|
|||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
//===================//
|
// tick update //
|
||||||
// menu UI lifecycle //
|
//=============//
|
||||||
//===================//
|
|
||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void updateScreen() { super.updateScreen(); }
|
|
||||||
#else
|
|
||||||
public void tick() { super.tick(); }
|
public void tick() { super.tick(); }
|
||||||
#endif
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
@@ -159,24 +117,14 @@ class DhConfigScreen extends DhScreen
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void initGui()
|
|
||||||
#else
|
|
||||||
protected void init()
|
protected void init()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
super.initGui();
|
|
||||||
#else
|
|
||||||
super.init();
|
super.init();
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!this.reload)
|
if (!this.reload)
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
// Changelog button
|
// Changelog button
|
||||||
if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()
|
if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()
|
||||||
// we only have changelogs for stable builds
|
// we only have changelogs for stable builds
|
||||||
@@ -204,7 +152,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
ChangelogScreen changelogScreen = new ChangelogScreen(this);
|
ChangelogScreen changelogScreen = new ChangelogScreen(this);
|
||||||
if (changelogScreen.usable)
|
if (changelogScreen.usable)
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(changelogScreen);
|
DhScreenUtil.showScreen(changelogScreen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -215,7 +163,6 @@ class DhConfigScreen extends DhScreen
|
|||||||
Translatable(ModInfo.ID + ".updater.title")
|
Translatable(ModInfo.ID + ".updater.title")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// back button
|
// back button
|
||||||
@@ -225,11 +172,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.showScreen(this.parent);
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// done/close button
|
// done/close button
|
||||||
@@ -240,30 +183,19 @@ class DhConfigScreen extends DhScreen
|
|||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.showScreen(this.parent);
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.mc, this.width * 2, this.height, 32, 32, 25);
|
|
||||||
#else
|
|
||||||
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
|
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||||
#elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
|
||||||
if (this.minecraft != null && this.minecraft.level != null)
|
if (this.minecraft != null && this.minecraft.level != null)
|
||||||
{
|
{
|
||||||
this.configListWidget.setRenderBackground(false);
|
this.configListWidget.setRenderBackground(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.addWidget(this.configListWidget);
|
this.addWidget(this.configListWidget);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (AbstractConfigBase<?> configEntry : ConfigHandler.INSTANCE.configBaseList)
|
for (AbstractConfigBase<?> configEntry : ConfigHandler.INSTANCE.configBaseList)
|
||||||
{
|
{
|
||||||
@@ -426,35 +358,18 @@ class DhConfigScreen extends DhScreen
|
|||||||
private static void setupBooleanMenuOption(ConfigEntry<Boolean> booleanConfigEntry)
|
private static void setupBooleanMenuOption(ConfigEntry<Boolean> booleanConfigEntry)
|
||||||
{
|
{
|
||||||
// For boolean
|
// For boolean
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Function<Object, ITextComponent> func = value -> Translatable("distanthorizons.general."+((Boolean) value ? "true" : "false")).setStyle(new Style().setColor((Boolean) value ? TextFormatting.GREEN : TextFormatting.RED));
|
|
||||||
#else
|
|
||||||
Function<Object, Component> func = value -> Translatable("distanthorizons.general." + ((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED);
|
Function<Object, Component> func = value -> Translatable("distanthorizons.general." + ((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED);
|
||||||
#endif
|
|
||||||
|
|
||||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue);
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue);
|
||||||
|
|
||||||
configGuiInfo.buttonOptionMap =
|
configGuiInfo.buttonOptionMap =
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
new AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>>(
|
|
||||||
#else
|
|
||||||
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||||
#endif
|
|
||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
button.enabled = !booleanConfigEntry.apiIsOverriding();
|
|
||||||
#else
|
|
||||||
button.active = !booleanConfigEntry.apiIsOverriding();
|
button.active = !booleanConfigEntry.apiIsOverriding();
|
||||||
#endif
|
|
||||||
|
|
||||||
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
|
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText();
|
|
||||||
#else
|
|
||||||
button.setMessage(func.apply(booleanConfigEntry.get()));
|
button.setMessage(func.apply(booleanConfigEntry.get()));
|
||||||
#endif
|
|
||||||
}, func);
|
}, func);
|
||||||
}
|
}
|
||||||
private static void setupEnumMenuOption(ConfigEntry<Enum<?>> enumConfigEntry, Class<? extends Enum<?>> enumClass)
|
private static void setupEnumMenuOption(ConfigEntry<Enum<?>> enumConfigEntry, Class<? extends Enum<?>> enumClass)
|
||||||
@@ -463,29 +378,20 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue);
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Function<Object, ITextComponent > getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
|
||||||
#else
|
|
||||||
Function<Object, Component> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
Function<Object, Component> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
||||||
#endif
|
|
||||||
|
|
||||||
configGuiInfo.buttonOptionMap =
|
configGuiInfo.buttonOptionMap =
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
new AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>>(
|
|
||||||
#else
|
|
||||||
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||||
#endif
|
|
||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
// get the currently selected enum and enum index
|
// get the currently selected enum and enum index
|
||||||
int startingIndex = enumList.indexOf(enumConfigEntry.get());
|
int startingIndex = enumList.indexOf(enumConfigEntry.get());
|
||||||
Enum<?> enumValue = enumList.get(startingIndex);
|
Enum<?> enumValue = enumList.get(startingIndex);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
boolean shiftPressed =
|
||||||
boolean shiftPressed = GuiScreen.isShiftKeyDown();
|
InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT)
|
||||||
#else
|
|| InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT);
|
||||||
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
|
// move forward or backwards depending on if the shift key is pressed
|
||||||
int index = shiftPressed ? startingIndex - 1 : startingIndex + 1;
|
int index = shiftPressed ? startingIndex - 1 : startingIndex + 1;
|
||||||
@@ -537,13 +443,9 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
enumConfigEntry.uiSetWithoutSaving(enumValue);
|
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.active = !enumConfigEntry.apiIsOverriding();
|
||||||
|
|
||||||
button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get()));
|
button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get()));
|
||||||
#endif
|
|
||||||
}, getEnumTranslatableFunc);
|
}, getEnumTranslatableFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,18 +461,12 @@ class DhConfigScreen extends DhScreen
|
|||||||
//==============//
|
//==============//
|
||||||
// reset button //
|
// reset button //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif btnAction = (button) ->
|
Button.OnPress btnAction = (button) ->
|
||||||
{
|
{
|
||||||
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
|
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
|
||||||
this.reload = true;
|
this.reload = true;
|
||||||
|
DhScreenUtil.showScreen(this);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this.parent, this.category));
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int resetButtonPosX = this.width
|
int resetButtonPosX = this.width
|
||||||
@@ -578,60 +474,29 @@ class DhConfigScreen extends DhScreen
|
|||||||
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
int resetButtonPosZ = 0;
|
int resetButtonPosZ = 0;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif resetButton = MakeBtn(
|
Button 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),
|
Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED),
|
||||||
#endif
|
|
||||||
resetButtonPosX, resetButtonPosZ,
|
resetButtonPosX, resetButtonPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
|
||||||
btnAction);
|
btnAction);
|
||||||
|
|
||||||
|
if (configEntry.apiIsOverriding())
|
||||||
if (configEntry.mcVersionOverridePresent())
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
resetButton.enabled = false;
|
|
||||||
resetButton.displayString = Translatable("distanthorizons.general.unsupportedMcVersion").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText();
|
|
||||||
#else
|
|
||||||
resetButton.active = false;
|
|
||||||
resetButton.setMessage(Translatable("distanthorizons.general.unsupportedMcVersion").withStyle(ChatFormatting.DARK_GRAY));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else 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.active = false;
|
||||||
resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY));
|
resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
resetButton.enabled = true;
|
|
||||||
#else
|
|
||||||
resetButton.active = true;
|
resetButton.active = true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
// option field //
|
// option field //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
||||||
#endif
|
|
||||||
|
|
||||||
int optionFieldPosX = this.width
|
int optionFieldPosX = this.width
|
||||||
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
|
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
|
||||||
@@ -643,40 +508,21 @@ class DhConfigScreen extends DhScreen
|
|||||||
if (configGuiInfo.buttonOptionMap != null)
|
if (configGuiInfo.buttonOptionMap != null)
|
||||||
{
|
{
|
||||||
// enum/multi option input button
|
// enum/multi option input button
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Map.Entry<OnPressed, Function<Object,ITextComponent>> widget = configGuiInfo.buttonOptionMap;
|
|
||||||
#else
|
|
||||||
Map.Entry<Button.OnPress, Function<Object, Component>> widget = configGuiInfo.buttonOptionMap;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
Map.Entry<Button.OnPress, Function<Object, Component>> widget = configGuiInfo.buttonOptionMap;
|
||||||
if (configEntry.getType().isEnum())
|
if (configEntry.getType().isEnum())
|
||||||
{
|
{
|
||||||
widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString()));
|
widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GuiButton button = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button button = MakeBtn(
|
Button button = MakeBtn(
|
||||||
#endif
|
|
||||||
widget.getValue().apply(configEntry.get()),
|
widget.getValue().apply(configEntry.get()),
|
||||||
optionFieldPosX, optionFieldPosZ,
|
optionFieldPosX, optionFieldPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
widget.getKey());
|
widget.getKey());
|
||||||
|
|
||||||
|
|
||||||
// deactivate the button if the API is overriding it
|
// deactivate the button if the API is overriding it
|
||||||
// or the MC version doesn't support it
|
button.active = !configEntry.apiIsOverriding();
|
||||||
if (configEntry.mcVersionOverridePresent()
|
|
||||||
|| configEntry.apiIsOverriding())
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
button.enabled = false;
|
|
||||||
#else
|
|
||||||
button.active = false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.configListWidget.addButton(this, configEntry,
|
this.configListWidget.addButton(this, configEntry,
|
||||||
@@ -690,25 +536,16 @@ class DhConfigScreen extends DhScreen
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// text box input
|
// text box input
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GuiTextField widget = new GuiTextField(0, this.fontRenderer,
|
|
||||||
optionFieldPosX, optionFieldPosZ,
|
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT);
|
|
||||||
widget.setMaxStringLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
|
||||||
widget.setText(String.valueOf(configEntry.get()));
|
|
||||||
#else
|
|
||||||
EditBox widget = new EditBox(this.font,
|
EditBox widget = new EditBox(this.font,
|
||||||
optionFieldPosX, optionFieldPosZ,
|
optionFieldPosX, optionFieldPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
Translatable(""));
|
Translatable(""));
|
||||||
widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
||||||
widget.insertText(String.valueOf(configEntry.get()));
|
widget.insertText(String.valueOf(configEntry.get()));
|
||||||
#endif
|
|
||||||
|
|
||||||
Predicate<String> processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton);
|
Predicate<String> processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton);
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
widget.setValidator(processor::test);
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
widget.setFilter(processor);
|
widget.setFilter(processor);
|
||||||
#else
|
#else
|
||||||
widget.setResponder(processor::test);
|
widget.setResponder(processor::test);
|
||||||
@@ -718,8 +555,6 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -730,31 +565,18 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
ConfigCategory configCategory = (ConfigCategory) configType;
|
ConfigCategory configCategory = (ConfigCategory) configType;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
||||||
#endif
|
|
||||||
|
|
||||||
int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored
|
int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
Button widget = MakeBtn(textComponent,
|
||||||
GuiButton widget = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button widget = MakeBtn(
|
|
||||||
#endif
|
|
||||||
textComponent,
|
|
||||||
categoryPosX, categoryPosZ,
|
categoryPosX, categoryPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
((button) ->
|
((button) ->
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.showScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
|
||||||
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);
|
this.configListWidget.addButton(this, configType, widget, null, null, null);
|
||||||
|
|
||||||
@@ -769,20 +591,11 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
ConfigUIButton configUiButton = (ConfigUIButton) configType;
|
ConfigUIButton configUiButton = (ConfigUIButton) configType;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
||||||
#endif
|
|
||||||
|
|
||||||
int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
Button widget = MakeBtn(textComponent,
|
||||||
GuiButton widget = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button widget = MakeBtn(
|
|
||||||
#endif
|
|
||||||
textComponent,
|
|
||||||
buttonPosX, this.height - 28,
|
buttonPosX, this.height - 28,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
(button) -> ((ConfigUIButton) configType).runAction());
|
(button) -> ((ConfigUIButton) configType).runAction());
|
||||||
@@ -799,11 +612,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
ConfigUIComment configUiComment = (ConfigUIComment) configType;
|
ConfigUIComment configUiComment = (ConfigUIComment) configType;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
||||||
#endif
|
|
||||||
if (configUiComment.parentConfigPath != null)
|
if (configUiComment.parentConfigPath != null)
|
||||||
{
|
{
|
||||||
textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath);
|
textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath);
|
||||||
@@ -820,12 +629,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
if (configType instanceof ConfigUISpacer)
|
if (configType instanceof ConfigUISpacer)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
Button spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"),
|
||||||
GuiButton spacerButton = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button spacerButton = MakeBtn(
|
|
||||||
#endif
|
|
||||||
Translatable("distanthorizons.general.spacer"),
|
|
||||||
10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1)
|
10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1)
|
||||||
1, 1,
|
1, 1,
|
||||||
(button) -> { });
|
(button) -> { });
|
||||||
@@ -850,11 +654,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private ITextComponent GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
|
||||||
#else
|
|
||||||
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
||||||
#endif
|
|
||||||
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); }
|
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -867,19 +667,15 @@ class DhConfigScreen extends DhScreen
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
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)
|
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
#else
|
#else
|
||||||
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function
|
||||||
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);
|
this.renderBackground(matrices);
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
super.render(matrices, mouseX, mouseY, delta);
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
@@ -888,9 +684,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Render buttons
|
// Render buttons
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
this.configListWidget.drawScreen(mouseX, mouseY, delta);
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
this.configListWidget.render(matrices, mouseX, mouseY, delta);
|
this.configListWidget.render(matrices, mouseX, mouseY, delta);
|
||||||
#else
|
#else
|
||||||
this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta);
|
this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta);
|
||||||
@@ -898,74 +692,51 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
|
|
||||||
// Render config title
|
// Render config title
|
||||||
this.DhDrawCenteredString(
|
this.DhDrawCenteredString(matrices, this.font, this.title,
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
matrices, this.font,
|
|
||||||
#endif
|
|
||||||
this.title,
|
|
||||||
this.width / 2, 15,
|
this.width / 2, 15,
|
||||||
#if MC_VER < MC_1_21_6
|
#if MC_VER < MC_1_21_6
|
||||||
0xFFFFFF // RGB white
|
0xFFFFFF // RGB white
|
||||||
#else
|
#else
|
||||||
0xFFFFFFFF // ARGB white
|
0xFFFFFFFF // ARGB white
|
||||||
#endif);
|
#endif );
|
||||||
|
|
||||||
|
|
||||||
// render DH version
|
// render DH version
|
||||||
this.DhDrawString(
|
this.DhDrawString(matrices, this.font, TextOrLiteral(ModInfo.VERSION), 2, this.height - 10,
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER < MC_1_21_6
|
||||||
matrices, this.font,
|
|
||||||
#endif
|
|
||||||
TextOrLiteral(ModInfo.VERSION), 2, this.height - 10,
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
0xAAAAAA // RGB white
|
0xAAAAAA // RGB white
|
||||||
#else
|
#else
|
||||||
0xFFAAAAAA // ARGB white
|
0xFFAAAAAA // ARGB white
|
||||||
#endif);
|
#endif );
|
||||||
|
|
||||||
// If the update is pending, display this message to inform the user that it will apply when the game restarts
|
// If the update is pending, display this message to inform the user that it will apply when the game restarts
|
||||||
if (SelfUpdater.deleteOldJarOnJvmShutdown)
|
if (SelfUpdater.deleteOldJarOnJvmShutdown)
|
||||||
{
|
{
|
||||||
this.DhDrawString(
|
this.DhDrawString(matrices, this.font, Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42,
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER < MC_1_21_6
|
||||||
matrices, this.font,
|
|
||||||
#endif
|
|
||||||
Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42,
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
0xFFFFFF // RGB white
|
0xFFFFFF // RGB white
|
||||||
#else
|
#else
|
||||||
0xFFFFFFFF // ARGB white
|
0xFFFFFFFF // ARGB white
|
||||||
#endif);
|
#endif );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.renderTooltip(mouseX, mouseY, delta);
|
|
||||||
#else
|
|
||||||
this.renderTooltip(matrices, mouseX, mouseY, delta);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
this.renderTooltip(matrices, mouseX, mouseY, delta);
|
||||||
super.drawScreen(mouseX, mouseY, delta);
|
|
||||||
#elif MC_VER < MC_1_20_2
|
#if MC_VER < MC_1_20_2
|
||||||
super.render(matrices, mouseX, mouseY, delta);
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
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)
|
private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
#else
|
#else
|
||||||
private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Gui hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
|
||||||
#else
|
|
||||||
AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
||||||
#endif
|
|
||||||
if (hoveredWidget == null)
|
if (hoveredWidget == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -981,21 +752,14 @@ class DhConfigScreen extends DhScreen
|
|||||||
button.dhConfigType;
|
button.dhConfigType;
|
||||||
|
|
||||||
boolean apiOverrideActive = false;
|
boolean apiOverrideActive = false;
|
||||||
boolean unsupportedMcVersion = false;
|
|
||||||
if (configBase instanceof ConfigEntry)
|
if (configBase instanceof ConfigEntry)
|
||||||
{
|
{
|
||||||
apiOverrideActive = ((ConfigEntry<?>) configBase).apiIsOverriding();
|
apiOverrideActive = ((ConfigEntry<?>) configBase).apiIsOverriding();
|
||||||
unsupportedMcVersion = ((ConfigEntry<?>) configBase).mcVersionOverridePresent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip";
|
String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip";
|
||||||
|
|
||||||
if (unsupportedMcVersion)
|
if (apiOverrideActive)
|
||||||
{
|
|
||||||
key = "distanthorizons.general.unsupportedMcVersion.@tooltip";
|
|
||||||
}
|
|
||||||
else if (apiOverrideActive)
|
|
||||||
{
|
{
|
||||||
key = "distanthorizons.general.disabledByApi.@tooltip";
|
key = "distanthorizons.general.disabledByApi.@tooltip";
|
||||||
}
|
}
|
||||||
@@ -1004,93 +768,22 @@ class DhConfigScreen extends DhScreen
|
|||||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
|
||||||
if (configGuiInfo.errorMessage != null)
|
if (configGuiInfo.errorMessage != null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.DhRenderTooltip(configGuiInfo.errorMessage, mouseX, mouseY);
|
|
||||||
#else
|
|
||||||
this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY);
|
this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// display the tooltip if present
|
// display the tooltip if present
|
||||||
else if (LANG_WRAPPER.langExists(key))
|
else if (LANG_WRAPPER.langExists(key))
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
List<ITextComponent> list = new ArrayList<>();
|
|
||||||
#else
|
|
||||||
List<Component> list = new ArrayList<>();
|
List<Component> list = new ArrayList<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
String lang = LANG_WRAPPER.getLang(key);
|
String lang = LANG_WRAPPER.getLang(key);
|
||||||
for (String langLine : lang.split("\n"))
|
for (String langLine : lang.split("\n"))
|
||||||
{
|
{
|
||||||
list.add(TextOrTranslatable(langLine));
|
list.add(TextOrTranslatable(langLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.DhRenderComponentTooltip(list, mouseX, mouseY);
|
|
||||||
#else
|
|
||||||
this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY);
|
this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws java.io.IOException
|
|
||||||
{
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
|
|
||||||
if (mouseY >= this.configListWidget.top && mouseY <= this.configListWidget.bottom)
|
|
||||||
{
|
|
||||||
for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children)
|
|
||||||
{
|
|
||||||
if (entry.button instanceof GuiButton btn && btn.visible)
|
|
||||||
{
|
|
||||||
if (btn.mousePressed(this.mc, mouseX, mouseY))
|
|
||||||
{
|
|
||||||
btn.playPressSound(this.mc.getSoundHandler());
|
|
||||||
OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(btn);
|
|
||||||
if (handler != null) handler.pressed(btn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (entry.button instanceof GuiTextField field && field.getVisible())
|
|
||||||
{
|
|
||||||
field.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entry.resetButton instanceof GuiButton reset && reset.visible)
|
|
||||||
{
|
|
||||||
if (reset.mousePressed(this.mc, mouseX, mouseY))
|
|
||||||
{
|
|
||||||
reset.playPressSound(this.mc.getSoundHandler());
|
|
||||||
OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(reset);
|
|
||||||
if (handler != null) handler.pressed(reset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws java.io.IOException
|
|
||||||
{
|
|
||||||
super.keyTyped(typedChar, keyCode);
|
|
||||||
for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children)
|
|
||||||
{
|
|
||||||
if (entry.button instanceof GuiTextField field)
|
|
||||||
{
|
|
||||||
field.textboxKeyTyped(typedChar, keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMouseInput() throws java.io.IOException
|
|
||||||
{
|
|
||||||
super.handleMouseInput();
|
|
||||||
this.configListWidget.handleMouseInput();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -1099,21 +792,19 @@ class DhConfigScreen extends DhScreen
|
|||||||
// shutdown //
|
// shutdown //
|
||||||
//==========//
|
//==========//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
/** When you close it, it goes to the previous screen and saves */
|
/** When you close it, it goes to the previous screen and saves */
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void onGuiClosed()
|
|
||||||
#else
|
|
||||||
public void onClose()
|
public void onClose()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
#if MC_VER > MC_1_12_2
|
DhScreenUtil.showScreen(this.parent);
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-22
@@ -2,16 +2,9 @@ package com.seibel.distanthorizons.common.wrappers.gui.config;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.core.config.gui.IConfigGuiInfo;
|
import com.seibel.distanthorizons.core.config.gui.IConfigGuiInfo;
|
||||||
import com.seibel.distanthorizons.core.config.types.AbstractConfigBase;
|
import com.seibel.distanthorizons.core.config.types.AbstractConfigBase;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.OnPressed;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiTextField;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
#endif
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
@@ -30,25 +23,11 @@ public class ConfigGuiInfo implements IConfigGuiInfo
|
|||||||
* Used to display validation errors.
|
* Used to display validation errors.
|
||||||
* Null if no error is present.
|
* Null if no error is present.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public ITextComponent errorMessage;
|
|
||||||
#else
|
|
||||||
public Component errorMessage;
|
public Component errorMessage;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public BiFunction<GuiTextField, GuiButton, Predicate<String>> tooltipFunction;
|
|
||||||
#else
|
|
||||||
public BiFunction<EditBox, Button , Predicate<String>> tooltipFunction;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
public BiFunction<EditBox, Button, Predicate<String>> tooltipFunction;
|
||||||
/** determines which options the button will show */
|
/** determines which options the button will show */
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>> buttonOptionMap;
|
|
||||||
#else
|
|
||||||
public AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>> buttonOptionMap;
|
public AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>> buttonOptionMap;
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -1,6 +1,7 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui.updater;
|
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.common.wrappers.gui.DhScreen;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||||
@@ -222,10 +223,7 @@ public class ChangelogScreen extends DhScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose()
|
public void onClose() { DhScreenUtil.showScreen(this.parent); }
|
||||||
{
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TextArea extends ContainerObjectSelectionList<ButtonEntry>
|
public static class TextArea extends ContainerObjectSelectionList<ButtonEntry>
|
||||||
{
|
{
|
||||||
@@ -297,4 +295,3 @@ public class ChangelogScreen extends DhScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+4
-4
@@ -1,7 +1,8 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui.updater;
|
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.api.enums.config.EDhApiUpdateBranch;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
||||||
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -137,7 +138,7 @@ public class UpdateModScreen extends DhScreen
|
|||||||
#endif
|
#endif
|
||||||
20, 20,
|
20, 20,
|
||||||
// Create the button and tell it where to go
|
// Create the button and tell it where to go
|
||||||
(buttonWidget) -> Objects.requireNonNull(this.minecraft).setScreen(new ChangelogScreen(this, this.newVersionID)),
|
(buttonWidget) -> DhScreenUtil.showScreen(new ChangelogScreen(this, this.newVersionID)),
|
||||||
// Add a title to the button
|
// Add a title to the button
|
||||||
Translatable(ModInfo.ID + ".updater.title")
|
Translatable(ModInfo.ID + ".updater.title")
|
||||||
));
|
));
|
||||||
@@ -218,8 +219,7 @@ public class UpdateModScreen extends DhScreen
|
|||||||
@Override
|
@Override
|
||||||
public void onClose()
|
public void onClose()
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Go to the parent screen
|
DhScreenUtil.showScreen(this.parent); // Go to the parent screen
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+11
-131
@@ -1,43 +1,20 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.level;
|
package com.seibel.distanthorizons.common.wrappers.level;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
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;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
#endif
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.WeakHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||||
{
|
{
|
||||||
public static final KeyedClientLevelManager INSTANCE = new KeyedClientLevelManager();
|
public static final KeyedClientLevelManager INSTANCE = new KeyedClientLevelManager();
|
||||||
|
|
||||||
private static class KeyInfo {
|
/** This is set and managed by the ClientApi for servers with support for DH. */
|
||||||
public final String serverKey;
|
@Nullable
|
||||||
public final String levelKey;
|
private IServerKeyedClientLevel serverKeyedLevel = null;
|
||||||
public KeyInfo(String serverKey, String levelKey) {
|
|
||||||
this.serverKey = serverKey;
|
|
||||||
this.levelKey = levelKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Stores the server-provided keys indexed by dimension name for persistence. */
|
|
||||||
private final Map<String, KeyInfo> keysByDimensionName = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
/** Cache for already keyed level wrappers to maintain object identity. */
|
|
||||||
private final Map<#if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif, IServerKeyedClientLevel> keyedLevelsCache = Collections.synchronizedMap(new WeakHashMap<>());
|
|
||||||
|
|
||||||
/** Allows to keep level manager enabled between loading different keyed levels */
|
/** Allows to keep level manager enabled between loading different keyed levels */
|
||||||
private volatile boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -45,131 +22,34 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
|||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
//region
|
|
||||||
|
|
||||||
private KeyedClientLevelManager() { }
|
private KeyedClientLevelManager() { }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//======================//
|
//======================//
|
||||||
// level override logic //
|
// level override logic //
|
||||||
//======================//
|
//======================//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public IServerKeyedClientLevel getServerKeyedLevel()
|
public IServerKeyedClientLevel getServerKeyedLevel() { return this.serverKeyedLevel; }
|
||||||
{
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
return this.getServerKeyedLevel(Minecraft.getInstance().level);
|
|
||||||
#else
|
|
||||||
return this.getServerKeyedLevel(Minecraft.getMinecraft().world);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public IServerKeyedClientLevel getServerKeyedLevel(@Nullable #if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif level)
|
|
||||||
{
|
|
||||||
if (level == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We synchronize on the cache map to ensure atomicity of the lookup-and-populate sequence.
|
|
||||||
// This prevents multiple threads from creating duplicate wrappers for the same level.
|
|
||||||
synchronized (this.keyedLevelsCache)
|
|
||||||
{
|
|
||||||
// Check the cache first
|
|
||||||
IServerKeyedClientLevel cached = this.keyedLevelsCache.get(level);
|
|
||||||
if (cached != null)
|
|
||||||
{
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine the dimension name for this level
|
|
||||||
// We use bypassLevelKeyManager=true to avoid recursion back into this manager
|
|
||||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level, true);
|
|
||||||
if (wrappedLevel == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String dimensionName = wrappedLevel.getDimensionName();
|
|
||||||
KeyInfo info = this.keysByDimensionName.get(dimensionName);
|
|
||||||
if (info == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and cache a new keyed wrapper
|
|
||||||
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper(level, info.serverKey, info.levelKey);
|
|
||||||
this.keyedLevelsCache.put(level, keyedLevel);
|
|
||||||
return keyedLevel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String serverKey, String levelKey)
|
public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String serverKey, String levelKey)
|
||||||
{
|
{
|
||||||
// 1. Determine the target dimension name
|
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper((ClientLevel) clientLevel.getWrappedMcObject(), serverKey, levelKey);
|
||||||
String targetDimensionName = clientLevel.getDimensionName();
|
this.serverKeyedLevel = keyedLevel;
|
||||||
int separatorIndex = levelKey.lastIndexOf("@");
|
|
||||||
if (separatorIndex != -1)
|
|
||||||
{
|
|
||||||
targetDimensionName = levelKey.substring(separatorIndex + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String finalTargetDimensionName = targetDimensionName;
|
|
||||||
|
|
||||||
// 2. Store the key for this dimension
|
|
||||||
this.keysByDimensionName.put(finalTargetDimensionName, new KeyInfo(serverKey, levelKey));
|
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
|
return keyedLevel;
|
||||||
// 3. Clear the cache for this dimension to ensure new wrappers are created with the new key
|
|
||||||
// (though in practice keys shouldn't change mid-session)
|
|
||||||
//
|
|
||||||
// We synchronize manually on the map to ensure atomicity of the compound removal operation
|
|
||||||
// and to prevent race conditions or deadlocks with other threads accessing the map.
|
|
||||||
// We avoid calling ClientLevelWrapper.getWrapper() inside the lock to prevent circular lock dependencies.
|
|
||||||
synchronized (this.keyedLevelsCache)
|
|
||||||
{
|
|
||||||
this.keyedLevelsCache.keySet().removeIf(level -> {
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
String levelDim = level.provider.getDimensionType().getName() + ":" + level.provider.getDimension();
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
String levelDim = level.dimension().location().toString();
|
|
||||||
#else
|
|
||||||
String levelDim = level.dimension().identifier().toString();
|
|
||||||
#endif
|
|
||||||
return levelDim.equals(finalTargetDimensionName);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Return the keyed wrapper for whatever level the core passed us,
|
|
||||||
// but only if it matches the dimension we just keyed.
|
|
||||||
return this.getServerKeyedLevel((#if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif) clientLevel.getWrappedMcObject());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearKeyedLevel()
|
public void clearKeyedLevel() { this.serverKeyedLevel = null; }
|
||||||
{
|
|
||||||
synchronized (this.keyedLevelsCache)
|
|
||||||
{
|
|
||||||
this.keyedLevelsCache.clear();
|
|
||||||
this.keysByDimensionName.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() { return this.enabled; }
|
public boolean isEnabled() { return this.enabled; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable()
|
public void disable() { this.enabled = false; }
|
||||||
{
|
|
||||||
this.enabled = false;
|
|
||||||
this.clearKeyedLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-17
@@ -2,11 +2,7 @@ package com.seibel.distanthorizons.common.wrappers.level;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
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;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
#endif
|
|
||||||
|
|
||||||
public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements IServerKeyedClientLevel
|
public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements IServerKeyedClientLevel
|
||||||
{
|
{
|
||||||
@@ -21,30 +17,21 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements
|
|||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public ServerKeyedClientLevelWrapper(WorldClient level, String serverKey, String serverLevelKey)
|
|
||||||
#else
|
|
||||||
public ServerKeyedClientLevelWrapper(ClientLevel level, String serverKey, String serverLevelKey)
|
public ServerKeyedClientLevelWrapper(ClientLevel level, String serverKey, String serverLevelKey)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
super(level);
|
super(level);
|
||||||
this.serverKey = serverKey;
|
this.serverKey = serverKey;
|
||||||
this.serverLevelKey = serverLevelKey;
|
this.serverLevelKey = serverLevelKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServerKey() { return this.serverKey; }
|
||||||
|
|
||||||
//======================//
|
//======================//
|
||||||
// level identification //
|
// level identification //
|
||||||
//======================//
|
//======================//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServerKey() { return this.serverKey; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getServerLevelKey() { return this.serverLevelKey; }
|
public String getServerLevelKey() { return this.serverLevelKey; }
|
||||||
@@ -52,8 +39,6 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements
|
|||||||
@Override
|
@Override
|
||||||
public String getDhIdentifier() { return this.getServerLevelKey(); }
|
public String getDhIdentifier() { return this.getServerLevelKey(); }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-258
@@ -20,20 +20,13 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.NativeDialogUtil;
|
import com.seibel.distanthorizons.common.wrappers.gui.NativeDialogUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
|
||||||
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
||||||
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
@@ -43,35 +36,19 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
|||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.ServerData;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.crash.CrashReport;
|
|
||||||
import net.minecraft.profiler.Profiler;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.ChunkPos;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraft.world.DimensionType;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
#else
|
|
||||||
import net.minecraft.CrashReport;
|
import net.minecraft.CrashReport;
|
||||||
import net.minecraft.client.CloudStatus;
|
import net.minecraft.client.CloudStatus;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -80,26 +57,11 @@ import net.minecraft.network.chat.TextComponent;
|
|||||||
import net.minecraft.util.profiling.Profiler;
|
import net.minecraft.util.profiling.Profiler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10 && MC_VER > MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.client.GraphicsStatus;
|
import net.minecraft.client.GraphicsStatus;
|
||||||
#else
|
#else
|
||||||
#endif
|
#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_19_2
|
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
#elif MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A singleton that wraps the Minecraft object.
|
* A singleton that wraps the Minecraft object.
|
||||||
*
|
*
|
||||||
@@ -108,23 +70,13 @@ import net.minecraft.core.Registry;
|
|||||||
public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper
|
public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper
|
||||||
{
|
{
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final Minecraft MINECRAFT = Minecraft.getMinecraft();
|
|
||||||
#else
|
|
||||||
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
||||||
#endif
|
|
||||||
|
|
||||||
public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper();
|
public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper();
|
||||||
|
|
||||||
|
|
||||||
private ProfilerWrapper profilerWrapper;
|
private ProfilerWrapper profilerWrapper;
|
||||||
|
|
||||||
// Need to classload this field later because otherwise it will be null even when Immersive Portals is present.
|
|
||||||
public static class Late {
|
|
||||||
private static final IImmersivePortalsAccessor IMMERSIVE_PORTALS = ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//======================//
|
//======================//
|
||||||
@@ -133,37 +85,20 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSinglePlayerServer()
|
public boolean hasSinglePlayerServer() { return MINECRAFT.hasSingleplayerServer(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return MINECRAFT.isSingleplayer();
|
|
||||||
#else
|
|
||||||
return MINECRAFT.hasSingleplayerServer();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public boolean clientConnectedToDedicatedServer()
|
public boolean clientConnectedToDedicatedServer()
|
||||||
{
|
{
|
||||||
return this.hasServerConnection()
|
return MINECRAFT.getCurrentServer() != null
|
||||||
&& !this.hasSinglePlayerServer();
|
&& !this.hasSinglePlayerServer();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean connectedToReplay()
|
public boolean connectedToReplay()
|
||||||
{
|
{
|
||||||
return !this.hasServerConnection()
|
return MINECRAFT.getCurrentServer() == null
|
||||||
&& !this.hasSinglePlayerServer() ;
|
&& !this.hasSinglePlayerServer() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasServerConnection()
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return MINECRAFT.getCurrentServerData() != null;
|
|
||||||
#else
|
|
||||||
return MINECRAFT.getCurrentServer() != null;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCurrentServerName()
|
public String getCurrentServerName()
|
||||||
{
|
{
|
||||||
@@ -173,13 +108,8 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ServerData server = MINECRAFT.getCurrentServerData();
|
|
||||||
return (server != null) ? server.serverName : "NULL";
|
|
||||||
#else
|
|
||||||
ServerData server = MINECRAFT.getCurrentServer();
|
ServerData server = MINECRAFT.getCurrentServer();
|
||||||
return (server != null) ? server.name : "NULL";
|
return (server != null) ? server.name : "NULL";
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@@ -191,44 +121,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerData server = getCurrentServerData();
|
ServerData server = MINECRAFT.getCurrentServer();
|
||||||
return getServerIp(server);
|
return (server != null) ? server.ip : "NA";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getCurrentServerVersion()
|
public String getCurrentServerVersion()
|
||||||
{
|
{
|
||||||
ServerData server = getCurrentServerData();
|
ServerData server = MINECRAFT.getCurrentServer();
|
||||||
return getServerVersion(server);
|
return (server != null) ? server.version.getString() : "UNKOWN";
|
||||||
}
|
|
||||||
|
|
||||||
private ServerData getCurrentServerData()
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return MINECRAFT.getCurrentServerData();
|
|
||||||
#else
|
|
||||||
return MINECRAFT.getCurrentServer();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
private String getServerIp(ServerData server)
|
|
||||||
{
|
|
||||||
if (server == null) { return "NA"; }
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return server.serverIP;
|
|
||||||
#else
|
|
||||||
return server.ip;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
private String getServerVersion(ServerData server)
|
|
||||||
{
|
|
||||||
if (server == null) { return "UNKOWN"; }
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return server.gameVersion;
|
|
||||||
#else
|
|
||||||
return server.version.getString();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -240,11 +141,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
//=================//
|
//=================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public EntityPlayerSP getPlayer() { return MINECRAFT.player; }
|
|
||||||
#else
|
|
||||||
public LocalPlayer getPlayer() { return MINECRAFT.player; }
|
public LocalPlayer getPlayer() { return MINECRAFT.player; }
|
||||||
#endif
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerExists() { return MINECRAFT.player != null; }
|
public boolean playerExists() { return MINECRAFT.player != null; }
|
||||||
@@ -252,52 +149,26 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
@Override
|
@Override
|
||||||
public DhBlockPos getPlayerBlockPos()
|
public DhBlockPos getPlayerBlockPos()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
EntityPlayerSP player = this.getPlayer();
|
|
||||||
#else
|
|
||||||
LocalPlayer player = this.getPlayer();
|
LocalPlayer player = this.getPlayer();
|
||||||
#endif
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
return new DhBlockPos(0, 0, 0);
|
return new DhBlockPos(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Late.IMMERSIVE_PORTALS != null)
|
|
||||||
{
|
|
||||||
DhBlockPos pos = Late.IMMERSIVE_PORTALS.getOriginalPlayerBlockPos();
|
|
||||||
if (pos != null) return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
BlockPos playerPos = player.getPosition();
|
|
||||||
#else
|
|
||||||
BlockPos playerPos = player.blockPosition();
|
BlockPos playerPos = player.blockPosition();
|
||||||
#endif
|
|
||||||
return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ());
|
return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DhChunkPos getPlayerChunkPos()
|
public DhChunkPos getPlayerChunkPos()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
EntityPlayerSP player = this.getPlayer();
|
|
||||||
#else
|
|
||||||
LocalPlayer player = this.getPlayer();
|
LocalPlayer player = this.getPlayer();
|
||||||
#endif
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
return new DhChunkPos(0, 0);
|
return new DhChunkPos(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Late.IMMERSIVE_PORTALS != null)
|
#if MC_VER < MC_1_17_1
|
||||||
{
|
|
||||||
DhChunkPos pos = Late.IMMERSIVE_PORTALS.getOriginalPlayerChunkPos();
|
|
||||||
if (pos != null) return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
#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());
|
ChunkPos playerPos = new ChunkPos(player.blockPosition());
|
||||||
#else
|
#else
|
||||||
ChunkPos playerPos = player.chunkPosition();
|
ChunkPos playerPos = player.chunkPosition();
|
||||||
@@ -327,16 +198,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
@Nullable
|
@Nullable
|
||||||
public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager)
|
public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager)
|
||||||
{
|
{
|
||||||
if (!bypassLevelKeyManager && Late.IMMERSIVE_PORTALS != null)
|
|
||||||
{
|
|
||||||
IClientLevelWrapper level = Late.IMMERSIVE_PORTALS.getOriginalClientLevelWrapper();
|
|
||||||
if (level != null) return level;
|
|
||||||
}
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
WorldClient level = MINECRAFT.world;
|
|
||||||
#else
|
|
||||||
ClientLevel level = MINECRAFT.level;
|
ClientLevel level = MINECRAFT.level;
|
||||||
#endif
|
|
||||||
if (level == null)
|
if (level == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -357,19 +219,13 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
@Override
|
@Override
|
||||||
public void sendChatMessage(String string)
|
public void sendChatMessage(String string)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
EntityPlayerSP player = this.getPlayer();
|
|
||||||
#else
|
|
||||||
LocalPlayer player = this.getPlayer();
|
LocalPlayer player = this.getPlayer();
|
||||||
#endif
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
player.sendMessage(new TextComponentString(string));
|
|
||||||
#elif MC_VER < MC_1_19_2
|
|
||||||
player.sendMessage(new TextComponent(string), getPlayer().getUUID());
|
player.sendMessage(new TextComponent(string), getPlayer().getUUID());
|
||||||
#elif MC_VER < MC_1_21_9
|
#elif MC_VER < MC_1_21_9
|
||||||
player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/false);
|
player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/false);
|
||||||
@@ -389,19 +245,13 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
@Override
|
@Override
|
||||||
public void sendOverlayMessage(String string)
|
public void sendOverlayMessage(String string)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
EntityPlayerSP player = this.getPlayer();
|
|
||||||
#else
|
|
||||||
LocalPlayer player = this.getPlayer();
|
LocalPlayer player = this.getPlayer();
|
||||||
#endif
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
MINECRAFT.ingameGUI.setOverlayMessage(string, /*animateColor*/false);
|
|
||||||
#elif MC_VER < MC_1_19_2
|
|
||||||
player.displayClientMessage(new TextComponent(string), /*isOverlay*/true);
|
player.displayClientMessage(new TextComponent(string), /*isOverlay*/true);
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/true);
|
player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/true);
|
||||||
@@ -423,9 +273,7 @@ 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.");
|
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_12_2
|
#if MC_VER <= MC_1_18_2
|
||||||
MINECRAFT.gameSettings.clouds = 0;
|
|
||||||
#elif MC_VER <= MC_1_18_2
|
|
||||||
MINECRAFT.options.renderClouds = CloudStatus.OFF;
|
MINECRAFT.options.renderClouds = CloudStatus.OFF;
|
||||||
#else
|
#else
|
||||||
MINECRAFT.options.cloudStatus().set(CloudStatus.OFF);
|
MINECRAFT.options.cloudStatus().set(CloudStatus.OFF);
|
||||||
@@ -434,13 +282,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
|
|
||||||
public void disableVanillaChunkFadeIn()
|
public void disableVanillaChunkFadeIn()
|
||||||
{
|
{
|
||||||
String message = "Disabling vanilla chunk fade in... This is done to prevent vanilla chunks from flashing on the Distant Horizons boarder when moving (which is distracting).";
|
LOGGER.info("Disabling vanilla chunk fade in... This is done to prevent vanilla chunks from flashing on the Distant Horizons boarder when moving (which is distracting).");
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
// chunk fade in was added MC 1.21.11
|
// chunk fade in was added MC 1.21.11
|
||||||
#else
|
#else
|
||||||
LOGGER.info(message);
|
|
||||||
|
|
||||||
MINECRAFT.options.chunkSectionFadeInTime().set(0.0);
|
MINECRAFT.options.chunkSectionFadeInTime().set(0.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -449,9 +295,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
{
|
{
|
||||||
String reasoning = "This is done to fix vanilla chunks (specifically water blocks) not fading into Distant Horizons LODs when DH's 'Vanilla Fade' option is enabled.";
|
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_12_2
|
#if MC_VER <= MC_1_18_2
|
||||||
// fabulous graphics was added in MC 1.16
|
|
||||||
#elif MC_VER <= MC_1_18_2
|
|
||||||
LOGGER.info("Disabling fabulous graphics... "+reasoning);
|
LOGGER.info("Disabling fabulous graphics... "+reasoning);
|
||||||
|
|
||||||
GraphicsStatus oldGraphicsStatus = MINECRAFT.options.graphicsMode;
|
GraphicsStatus oldGraphicsStatus = MINECRAFT.options.graphicsMode;
|
||||||
@@ -487,7 +331,6 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
* no override and not included in {@link IMinecraftClientWrapper}
|
* no override and not included in {@link IMinecraftClientWrapper}
|
||||||
* since this would only be used in common/client, not core.
|
* since this would only be used in common/client, not core.
|
||||||
*/
|
*/
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public
|
public
|
||||||
#if MC_VER < MC_1_21_9 long
|
#if MC_VER < MC_1_21_9 long
|
||||||
#else Window
|
#else Window
|
||||||
@@ -501,20 +344,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
return MINECRAFT.getWindow();
|
return MINECRAFT.getWindow();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IProfilerWrapper getProfiler()
|
public IProfilerWrapper getProfiler()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Profiler profiler;
|
|
||||||
#else
|
|
||||||
ProfilerFiller profiler;
|
ProfilerFiller profiler;
|
||||||
#endif
|
#if MC_VER < MC_1_21_3
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
profiler = MINECRAFT.profiler;
|
|
||||||
#elif MC_VER < MC_1_21_3
|
|
||||||
profiler = MINECRAFT.getProfiler();
|
profiler = MINECRAFT.getProfiler();
|
||||||
#else
|
#else
|
||||||
profiler = Profiler.get();
|
profiler = Profiler.get();
|
||||||
@@ -543,9 +378,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
executeOnRenderThread(() ->
|
executeOnRenderThread(() ->
|
||||||
{
|
{
|
||||||
CrashReport report = new CrashReport(errorMessage, exception);
|
CrashReport report = new CrashReport(errorMessage, exception);
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_4
|
||||||
MINECRAFT.crashed(report);
|
|
||||||
#elif MC_VER < MC_1_20_4
|
|
||||||
Minecraft.crash(report);
|
Minecraft.crash(report);
|
||||||
#else
|
#else
|
||||||
MINECRAFT.delayCrash(report);
|
MINECRAFT.delayCrash(report);
|
||||||
@@ -554,14 +387,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeOnRenderThread(Runnable runnable)
|
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
MINECRAFT.addScheduledTask(runnable);
|
|
||||||
#else
|
|
||||||
MINECRAFT.execute(runnable);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showDialog(String title, String message, String dialogType, String iconType)
|
public void showDialog(String title, String message, String dialogType, String iconType)
|
||||||
@@ -577,14 +403,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getOptionsObject()
|
public Object getOptionsObject() { return MINECRAFT.options; }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return MINECRAFT.gameSettings;
|
|
||||||
#else
|
|
||||||
return MINECRAFT.options;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
@@ -599,75 +418,22 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
|||||||
public boolean isDedicatedServer() { return false; }
|
public boolean isDedicatedServer() { return false; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getInstallationDirectory()
|
public File getInstallationDirectory() { return MINECRAFT.gameDirectory; }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return MINECRAFT.gameDir;
|
|
||||||
#else
|
|
||||||
return MINECRAFT.gameDirectory;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerCount()
|
public int getPlayerCount()
|
||||||
{
|
{
|
||||||
// can be null if the server hasn't finished booting up yet
|
// can be null if the server hasn't finished booting up yet
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
if (MINECRAFT.getIntegratedServer() == null)
|
|
||||||
#else
|
|
||||||
if (MINECRAFT.getSingleplayerServer() == null)
|
if (MINECRAFT.getSingleplayerServer() == null)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return MINECRAFT.getIntegratedServer().getCurrentPlayerCount();
|
|
||||||
#else
|
|
||||||
return MINECRAFT.getSingleplayerServer().getPlayerCount();
|
return MINECRAFT.getSingleplayerServer().getPlayerCount();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IServerLevelWrapper getWrappedServerLevel(String levelKey)
|
|
||||||
{
|
|
||||||
if (!hasSinglePlayerServer()) return null;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
int dimensionID;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dimensionID = Integer.parseInt(levelKey.substring(levelKey.indexOf(":")+1));
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ignored)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#if MC_VER <= MC_1_21_10
|
|
||||||
ResourceLocation levelID = ResourceLocation.tryParse(levelKey);
|
|
||||||
#else
|
|
||||||
Identifier levelID = Identifier.tryParse(levelKey);
|
|
||||||
#endif
|
|
||||||
if (levelID == null) return null;
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_19_2
|
|
||||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registries.DIMENSION, levelID);
|
|
||||||
#else
|
|
||||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, levelID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
WorldServer level = MINECRAFT.getIntegratedServer().getWorld(dimensionID);
|
|
||||||
#else
|
|
||||||
ServerLevel level = MINECRAFT.getSingleplayerServer().getLevel(resourceKey);
|
|
||||||
#endif
|
|
||||||
return ServerLevelWrapper.getWrapper(level);
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-76
@@ -19,9 +19,7 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_5
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
#elif MC_VER < MC_1_21_5
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
#else
|
#else
|
||||||
import com.mojang.blaze3d.opengl.GlStateManager;
|
import com.mojang.blaze3d.opengl.GlStateManager;
|
||||||
@@ -71,17 +69,13 @@ public class MinecraftGLWrapper
|
|||||||
public void enableScissorTest()
|
public void enableScissorTest()
|
||||||
{
|
{
|
||||||
GL32.glEnable(GL32.GL_SCISSOR_TEST);
|
GL32.glEnable(GL32.GL_SCISSOR_TEST);
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
GlStateManager._enableScissorTest();
|
GlStateManager._enableScissorTest();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/** @see GL32#GL_SCISSOR_TEST */
|
/** @see GL32#GL_SCISSOR_TEST */
|
||||||
public void disableScissorTest()
|
public void disableScissorTest()
|
||||||
{
|
{
|
||||||
GL32.glDisable(GL32.GL_SCISSOR_TEST);
|
GL32.glDisable(GL32.GL_SCISSOR_TEST);
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
GlStateManager._disableScissorTest();
|
GlStateManager._disableScissorTest();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -99,53 +93,33 @@ public class MinecraftGLWrapper
|
|||||||
public void enableDepthTest()
|
public void enableDepthTest()
|
||||||
{
|
{
|
||||||
GL32.glEnable(GL32.GL_DEPTH_TEST);
|
GL32.glEnable(GL32.GL_DEPTH_TEST);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.enableDepth();
|
|
||||||
#else
|
|
||||||
GlStateManager._enableDepthTest();
|
GlStateManager._enableDepthTest();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/** @see GL32#GL_DEPTH_TEST */
|
/** @see GL32#GL_DEPTH_TEST */
|
||||||
public void disableDepthTest()
|
public void disableDepthTest()
|
||||||
{
|
{
|
||||||
GL32.glDisable(GL32.GL_DEPTH_TEST);
|
GL32.glDisable(GL32.GL_DEPTH_TEST);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.disableDepth();
|
|
||||||
#else
|
|
||||||
GlStateManager._disableDepthTest();
|
GlStateManager._disableDepthTest();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see GL32#glDepthFunc(int) */
|
/** @see GL32#glDepthFunc(int) */
|
||||||
public void glDepthFunc(int func)
|
public void glDepthFunc(int func)
|
||||||
{
|
{
|
||||||
GL32.glDepthFunc(func);
|
GL32.glDepthFunc(func);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.depthFunc(func);
|
|
||||||
#else
|
|
||||||
GlStateManager._depthFunc(func);
|
GlStateManager._depthFunc(func);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see GL32#glDepthMask(boolean) */
|
/** @see GL32#glDepthMask(boolean) */
|
||||||
public void enableDepthMask()
|
public void enableDepthMask()
|
||||||
{
|
{
|
||||||
GL32.glDepthMask(true);
|
GL32.glDepthMask(true);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.depthMask(true);
|
|
||||||
#else
|
|
||||||
GlStateManager._depthMask(true);
|
GlStateManager._depthMask(true);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/** @see GL32#glDepthMask(boolean) */
|
/** @see GL32#glDepthMask(boolean) */
|
||||||
public void disableDepthMask()
|
public void disableDepthMask()
|
||||||
{
|
{
|
||||||
GL32.glDepthMask(false);
|
GL32.glDepthMask(false);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.depthMask(false);
|
|
||||||
#else
|
|
||||||
GlStateManager._depthMask(false);
|
GlStateManager._depthMask(false);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -155,30 +129,21 @@ public class MinecraftGLWrapper
|
|||||||
public void enableBlend()
|
public void enableBlend()
|
||||||
{
|
{
|
||||||
GL32.glEnable(GL32.GL_BLEND);
|
GL32.glEnable(GL32.GL_BLEND);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
#else
|
|
||||||
GlStateManager._enableBlend();
|
GlStateManager._enableBlend();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/** @see GL32#GL_BLEND */
|
/** @see GL32#GL_BLEND */
|
||||||
public void disableBlend()
|
public void disableBlend()
|
||||||
{
|
{
|
||||||
GL32.glDisable(GL32.GL_BLEND);
|
GL32.glDisable(GL32.GL_BLEND);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.disableBlend();
|
|
||||||
#else
|
|
||||||
GlStateManager._disableBlend();
|
GlStateManager._disableBlend();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see GL32#glBlendFunc */
|
/** @see GL32#glBlendFunc */
|
||||||
public void glBlendFunc(int sfactor, int dfactor)
|
public void glBlendFunc(int sfactor, int dfactor)
|
||||||
{
|
{
|
||||||
GL32.glBlendFunc(sfactor, dfactor);
|
GL32.glBlendFunc(sfactor, dfactor);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.blendFunc(sfactor, dfactor);
|
#if MC_VER < MC_1_21_5
|
||||||
#elif MC_VER < MC_1_21_5
|
|
||||||
GlStateManager._blendFunc(sfactor, dfactor);
|
GlStateManager._blendFunc(sfactor, dfactor);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -186,11 +151,7 @@ public class MinecraftGLWrapper
|
|||||||
public void glBlendFuncSeparate(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha)
|
public void glBlendFuncSeparate(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha)
|
||||||
{
|
{
|
||||||
GL32.glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
GL32.glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.tryBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
|
||||||
#else
|
|
||||||
GlStateManager._blendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
GlStateManager._blendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -200,9 +161,7 @@ public class MinecraftGLWrapper
|
|||||||
public void glBindFramebuffer(int target, int framebuffer)
|
public void glBindFramebuffer(int target, int framebuffer)
|
||||||
{
|
{
|
||||||
GL32.glBindFramebuffer(target, framebuffer);
|
GL32.glBindFramebuffer(target, framebuffer);
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
GlStateManager._glBindFramebuffer(target, framebuffer);
|
GlStateManager._glBindFramebuffer(target, framebuffer);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -231,54 +190,28 @@ public class MinecraftGLWrapper
|
|||||||
public void enableFaceCulling()
|
public void enableFaceCulling()
|
||||||
{
|
{
|
||||||
GL32.glEnable(GL32.GL_CULL_FACE);
|
GL32.glEnable(GL32.GL_CULL_FACE);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.enableCull();
|
|
||||||
#else
|
|
||||||
GlStateManager._enableCull();
|
GlStateManager._enableCull();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/** @see GL32#GL_CULL_FACE */
|
/** @see GL32#GL_CULL_FACE */
|
||||||
public void disableFaceCulling()
|
public void disableFaceCulling()
|
||||||
{
|
{
|
||||||
GL32.glDisable(GL32.GL_CULL_FACE);
|
GL32.glDisable(GL32.GL_CULL_FACE);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.disableCull();
|
|
||||||
#else
|
|
||||||
GlStateManager._disableCull();
|
GlStateManager._disableCull();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// textures //
|
// textures //
|
||||||
|
|
||||||
/** @see GL32#glGenTextures() */
|
/** @see GL32#glGenTextures() */
|
||||||
public int glGenTextures()
|
public int glGenTextures() { return GlStateManager._genTexture(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return GlStateManager.generateTexture();
|
|
||||||
#else
|
|
||||||
return GlStateManager._genTexture();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/** @see GL32#glDeleteTextures(int) */
|
/** @see GL32#glDeleteTextures(int) */
|
||||||
public void glDeleteTextures(int texture)
|
public void glDeleteTextures(int texture) { GlStateManager._deleteTexture(texture); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.deleteTexture(texture);
|
|
||||||
#else
|
|
||||||
GlStateManager._deleteTexture(texture);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @see GL32#glActiveTexture(int) */
|
/** @see GL32#glActiveTexture(int) */
|
||||||
public void glActiveTexture(int textureId)
|
public void glActiveTexture(int textureId)
|
||||||
{
|
{
|
||||||
GL32.glActiveTexture(textureId);
|
GL32.glActiveTexture(textureId);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.setActiveTexture(textureId);
|
|
||||||
#else
|
|
||||||
GlStateManager._activeTexture(textureId);
|
GlStateManager._activeTexture(textureId);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
public int getActiveTexture() { return GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D); }
|
public int getActiveTexture() { return GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D); }
|
||||||
|
|
||||||
@@ -289,11 +222,7 @@ public class MinecraftGLWrapper
|
|||||||
public void glBindTexture(int texture)
|
public void glBindTexture(int texture)
|
||||||
{
|
{
|
||||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, texture);
|
GL32.glBindTexture(GL32.GL_TEXTURE_2D, texture);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GlStateManager.bindTexture(texture);
|
|
||||||
#else
|
|
||||||
GlStateManager._bindTexture(texture);
|
GlStateManager._bindTexture(texture);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+108
-159
@@ -20,34 +20,27 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
import com.mojang.blaze3d.platform.NativeImage;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|
||||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||||
|
|
||||||
#if MC_VER < MC_1_17_1
|
#if MC_VER < MC_1_17_1
|
||||||
#elif MC_VER < MC_1_21_3
|
#elif MC_VER < MC_1_21_6
|
||||||
import net.minecraft.client.renderer.FogRenderer;
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
#elif MC_VER < MC_1_21_6
|
|
||||||
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
|
||||||
import net.minecraft.client.renderer.FogRenderer;
|
|
||||||
#else
|
#else
|
||||||
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
|
||||||
import net.minecraft.client.renderer.fog.FogData;
|
import net.minecraft.client.renderer.fog.FogData;
|
||||||
import net.minecraft.client.renderer.fog.FogRenderer;
|
import net.minecraft.client.renderer.fog.FogRenderer;
|
||||||
#endif
|
#endif
|
||||||
@@ -58,38 +51,27 @@ import org.joml.Vector3f;
|
|||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
|
||||||
import net.minecraft.init.MobEffects;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
#endif
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
import org.lwjgl.opengl.GL15;
|
|
||||||
#elif MC_VER < MC_1_17_1
|
|
||||||
import net.minecraft.tags.FluidTags;
|
import net.minecraft.tags.FluidTags;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
@@ -118,20 +100,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
|
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
|
||||||
|
|
||||||
private static final IOptifineAccessor OPTIFINE_ACCESSOR = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class);
|
private static final IOptifineAccessor OPTIFINE_ACCESSOR = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class);
|
||||||
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
|
||||||
|
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final Minecraft MC = Minecraft.getMinecraft();
|
|
||||||
#else
|
|
||||||
private static final Minecraft MC = Minecraft.getInstance();
|
private static final Minecraft MC = Minecraft.getInstance();
|
||||||
#endif
|
|
||||||
|
|
||||||
// Need to classload this field later because otherwise it will be null even when Immersive Portals is present.
|
|
||||||
public static class Late {
|
|
||||||
private static final IImmersivePortalsAccessor IMMERSIVE_PORTALS = ModAccessorInjector.INSTANCE.get(IImmersivePortalsAccessor.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the case of immersive portals multiple levels may be active at once, causing conflicting lightmaps. <br>
|
* In the case of immersive portals multiple levels may be active at once, causing conflicting lightmaps. <br>
|
||||||
@@ -162,15 +133,15 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
@Override
|
@Override
|
||||||
public Vec3f getLookAtVector()
|
public Vec3f getLookAtVector()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
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();
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
return new Vec3f(camera.getLookVector().x(), camera.getLookVector().y(), camera.getLookVector().z());
|
return new Vec3f(camera.getLookVector().x(), camera.getLookVector().y(), camera.getLookVector().z());
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
Camera camera = MC.gameRenderer.getMainCamera();
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
return new Vec3f(camera.forwardVector().x(), camera.forwardVector().y(), camera.forwardVector().z());
|
return new Vec3f(camera.forwardVector().x(), camera.forwardVector().y(), camera.forwardVector().z());
|
||||||
|
#else
|
||||||
|
Camera camera = MC.gameRenderer.mainCamera();
|
||||||
|
return new Vec3f(camera.forwardVector().x(), camera.forwardVector().y(), camera.forwardVector().z());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,57 +156,42 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (MC.player.getActiveEffectsMap() == null)
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
if (MC.player.getActivePotionMap() == null)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null;
|
|
||||||
#else
|
|
||||||
if (MC.player.getActiveEffectsMap() == null)
|
|
||||||
{
|
{
|
||||||
return false;
|
return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null
|
||||||
|
#if MC_VER >= MC_1_19_2
|
||||||
|
|| MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect
|
||||||
|
#endif
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public Vec3d getCameraExactPosition()
|
public Vec3d getCameraExactPosition()
|
||||||
{
|
{
|
||||||
if (Late.IMMERSIVE_PORTALS != null)
|
#if MC_VER <= MC_26_1_2
|
||||||
{
|
|
||||||
Vec3d cameraPos = Late.IMMERSIVE_PORTALS.getOriginalCameraPos();
|
|
||||||
if (cameraPos != null) return cameraPos;
|
|
||||||
}
|
|
||||||
#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();
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
|
#else
|
||||||
|
Camera camera = MC.gameRenderer.mainCamera();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
Vec3 projectedView = camera.getPosition();
|
Vec3 projectedView = camera.getPosition();
|
||||||
#else
|
#else
|
||||||
Vec3 projectedView = camera.position();
|
Vec3 projectedView = camera.position();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
|
return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getPartialTickTime()
|
public float getPartialTickTime()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_1
|
||||||
return MC.getRenderPartialTicks();
|
|
||||||
#elif MC_VER < MC_1_21_1
|
|
||||||
return MC.getFrameTime();
|
return MC.getFrameTime();
|
||||||
#elif MC_VER < MC_1_21_3
|
#elif MC_VER < MC_1_21_3
|
||||||
return MC.getTimer().getRealtimeDeltaTicks();
|
return MC.getTimer().getRealtimeDeltaTicks();
|
||||||
@@ -315,20 +271,29 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
float darkenAmount;
|
float darkenAmount;
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
darkenAmount = MC.gameRenderer.getDarkenWorldAmount(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
darkenAmount = MC.gameRenderer.getDarkenWorldAmount(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
darkenAmount = MC.gameRenderer.getBossOverlayWorldDarkening(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
darkenAmount = MC.gameRenderer.getBossOverlayWorldDarkening(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
||||||
|
#else
|
||||||
|
darkenAmount = MC.gameRenderer.bossOverlayWorldDarkening(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
|
#else
|
||||||
|
Camera camera = MC.gameRenderer.mainCamera();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
Vector4f colorValues = mcFogRenderer.setupFog(
|
Vector4f colorValues = mcFogRenderer.setupFog(
|
||||||
MC.gameRenderer.getMainCamera(),
|
camera,
|
||||||
MC.options.getEffectiveRenderDistance(),
|
MC.options.getEffectiveRenderDistance(),
|
||||||
MC.deltaTracker,
|
MC.deltaTracker,
|
||||||
darkenAmount,
|
darkenAmount,
|
||||||
MC.level);
|
MC.level);
|
||||||
#else
|
#else
|
||||||
FogData fogData = mcFogRenderer.setupFog(
|
FogData fogData = mcFogRenderer.setupFog(
|
||||||
MC.gameRenderer.getMainCamera(),
|
camera,
|
||||||
MC.options.getEffectiveRenderDistance(),
|
MC.options.getEffectiveRenderDistance(),
|
||||||
MC.deltaTracker,
|
MC.deltaTracker,
|
||||||
darkenAmount,
|
darkenAmount,
|
||||||
@@ -348,17 +313,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
@Override
|
@Override
|
||||||
public Color getSkyColor()
|
public Color getSkyColor()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
if (MC.world.provider.hasSkyLight())
|
|
||||||
#else
|
|
||||||
if (MC.level.dimensionType().hasSkyLight())
|
if (MC.level.dimensionType().hasSkyLight())
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
float frameTime = this.getPartialTickTime();
|
|
||||||
net.minecraft.util.math.Vec3d colorValues = MC.world.getSkyColor(MC.getRenderViewEntity(), frameTime);
|
|
||||||
return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
|
|
||||||
#elif MC_VER < MC_1_17_1
|
|
||||||
float frameTime = this.getPartialTickTime();
|
float frameTime = this.getPartialTickTime();
|
||||||
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), frameTime);
|
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), frameTime);
|
||||||
return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
|
return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
|
||||||
@@ -385,9 +342,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
@Override
|
@Override
|
||||||
public int getRenderDistance()
|
public int getRenderDistance()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_17_1
|
||||||
return MC.gameSettings.renderDistanceChunks;
|
|
||||||
#elif MC_VER <= MC_1_17_1
|
|
||||||
return MC.options.renderDistance;
|
return MC.options.renderDistance;
|
||||||
#else
|
#else
|
||||||
return MC.options.getEffectiveRenderDistance();
|
return MC.options.getEffectiveRenderDistance();
|
||||||
@@ -397,18 +352,21 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
@Override
|
@Override
|
||||||
public int getFrameLimit()
|
public int getFrameLimit()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_18_2
|
||||||
return MC.gameSettings.limitFramerate;
|
|
||||||
#elif MC_VER <= MC_1_18_2
|
|
||||||
return MC.options.framerateLimit;
|
return MC.options.framerateLimit;
|
||||||
#else
|
#else
|
||||||
return MC.options.framerateLimit().get();
|
return MC.options.framerateLimit().get();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
public RenderTarget getRenderTarget()
|
||||||
protected RenderTarget getRenderTarget() { return MC.getMainRenderTarget(); }
|
{
|
||||||
#endif
|
#if MC_VER <= MC_26_1_2
|
||||||
|
return MC.getMainRenderTarget();
|
||||||
|
#else
|
||||||
|
return MC.gameRenderer.mainRenderTarget();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mcRendersToFrameBuffer()
|
public boolean mcRendersToFrameBuffer()
|
||||||
@@ -439,9 +397,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
return this.finalLevelFrameBufferId;
|
return this.finalLevelFrameBufferId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_5
|
||||||
return MC.getFramebuffer().framebufferObject;
|
|
||||||
#elif MC_VER < MC_1_21_5
|
|
||||||
return this.getRenderTarget().frameBufferId;
|
return this.getRenderTarget().frameBufferId;
|
||||||
#else
|
#else
|
||||||
// MC renders to a texture and then directly to the default FBO now
|
// MC renders to a texture and then directly to the default FBO now
|
||||||
@@ -456,10 +412,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
@Override
|
@Override
|
||||||
public int getDepthTextureId()
|
public int getDepthTextureId()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_5
|
||||||
//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();
|
return this.getRenderTarget().getDepthTextureId();
|
||||||
#else
|
#else
|
||||||
try
|
try
|
||||||
@@ -486,12 +439,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
// TODO vulkan deprecate(?) and add method to get color texture
|
||||||
@Override
|
@Override
|
||||||
public int getColorTextureId()
|
public int getColorTextureId()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_5
|
||||||
return MC.getFramebuffer().framebufferTexture;
|
|
||||||
#elif MC_VER < MC_1_21_5
|
|
||||||
return this.getRenderTarget().getColorTextureId();
|
return this.getRenderTarget().getColorTextureId();
|
||||||
#else
|
#else
|
||||||
try
|
try
|
||||||
@@ -521,9 +473,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
@Override
|
@Override
|
||||||
public int getTargetFramebufferViewportWidth()
|
public int getTargetFramebufferViewportWidth()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_9
|
||||||
return MC.getFramebuffer().framebufferWidth;
|
|
||||||
#elif MC_VER < MC_1_21_9
|
|
||||||
return this.getRenderTarget().viewWidth;
|
return this.getRenderTarget().viewWidth;
|
||||||
#else
|
#else
|
||||||
return this.getRenderTarget().width;
|
return this.getRenderTarget().width;
|
||||||
@@ -533,23 +483,20 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
@Override
|
@Override
|
||||||
public int getTargetFramebufferViewportHeight()
|
public int getTargetFramebufferViewportHeight()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_9
|
||||||
return MC.getFramebuffer().framebufferHeight;
|
|
||||||
#elif MC_VER < MC_1_21_9
|
|
||||||
return this.getRenderTarget().viewHeight;
|
return this.getRenderTarget().viewHeight;
|
||||||
#else
|
#else
|
||||||
return this.getRenderTarget().height;
|
return this.getRenderTarget().height;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILightMapWrapper getLightmapWrapper(@NotNull ILevelWrapper level) { return this.lightmapByDimensionType.get(level.getDimensionType()); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFogStateSpecial()
|
public boolean isFogStateSpecial()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_17_1
|
||||||
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();
|
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
FluidState fluidState = camera.getFluidInCamera();
|
FluidState fluidState = camera.getFluidInCamera();
|
||||||
Entity entity = camera.getEntity();
|
Entity entity = camera.getEntity();
|
||||||
@@ -557,95 +504,97 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
isBlind |= fluidState.is(FluidTags.WATER);
|
isBlind |= fluidState.is(FluidTags.WATER);
|
||||||
isBlind |= fluidState.is(FluidTags.LAVA);
|
isBlind |= fluidState.is(FluidTags.LAVA);
|
||||||
return isBlind;
|
return isBlind;
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
boolean isBlind = this.playerHasBlindingEffect();
|
boolean isBlind = this.playerHasBlindingEffect();
|
||||||
return MC.gameRenderer.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
return MC.gameRenderer.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
||||||
|
#else
|
||||||
|
boolean isBlind = this.playerHasBlindingEffect();
|
||||||
|
return MC.gameRenderer.mainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==========//
|
|
||||||
// lightmap //
|
|
||||||
//==========//
|
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILightMapWrapper getLightmapWrapper(@NotNull ILevelWrapper level) { return this.lightmapByDimensionType.get(level.getDimensionType()); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's better to use {@link MinecraftRenderWrapper#setLightmapId(int)} if possible,
|
* It's better to use {@link MinecraftRenderWrapper#setLightmapId(int, IClientLevelWrapper)} if possible,
|
||||||
* however old MC versions don't support it.
|
* however old MC versions don't support it.
|
||||||
*/
|
*/
|
||||||
#if MC_VER > MC_1_12_2
|
public void updateLightmap(NativeImage lightPixels, IClientLevelWrapper level)
|
||||||
public void updateLightmap(NativeImage lightPixels)
|
|
||||||
{
|
{
|
||||||
IClientLevelWrapper clientLevel = getLightmapClientLevelWrapper();
|
|
||||||
if (clientLevel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
|
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
|
||||||
// object for the same MC level and/or the same hash,
|
// object for the same MC level and/or the same hash,
|
||||||
// so this will have to do for now
|
// so this will have to do for now
|
||||||
IDimensionTypeWrapper dimensionType = clientLevel.getDimensionType();
|
IDimensionTypeWrapper dimensionType = level.getDimensionType();
|
||||||
|
|
||||||
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
||||||
wrapper.uploadLightmap(lightPixels);
|
wrapper.uploadLightmap(lightPixels);
|
||||||
}
|
}
|
||||||
#endif
|
public void setLightmapId(int tetxureId, IClientLevelWrapper level)
|
||||||
|
|
||||||
public void setLightmapId(int textureId)
|
|
||||||
{
|
{
|
||||||
IClientLevelWrapper clientLevel = getLightmapClientLevelWrapper();
|
|
||||||
if (clientLevel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
|
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
|
||||||
// object for the same MC level and/or the same hash,
|
// object for the same MC level and/or the same hash,
|
||||||
// so this will have to do for now
|
// so this will have to do for now
|
||||||
IDimensionTypeWrapper dimensionType = clientLevel.getDimensionType();
|
IDimensionTypeWrapper dimensionType = level.getDimensionType();
|
||||||
|
|
||||||
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
||||||
wrapper.setLightmapId(textureId);
|
wrapper.setLightmapId(tetxureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
#else
|
#else
|
||||||
public void setLightmapGpuTexture(GpuTexture gpuTexture)
|
public void setLightmapGpuTexture(GpuTexture gpuTexture, IClientLevelWrapper level)
|
||||||
{
|
{
|
||||||
IClientLevelWrapper clientLevel = getLightmapClientLevelWrapper();
|
|
||||||
if (clientLevel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
|
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
|
||||||
// object for the same MC level and/or the same hash,
|
// object for the same MC level and/or the same hash,
|
||||||
// so this will have to do for now
|
// so this will have to do for now
|
||||||
IDimensionTypeWrapper dimensionType = clientLevel.getDimensionType();
|
IDimensionTypeWrapper dimensionType = level.getDimensionType();
|
||||||
|
|
||||||
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
||||||
wrapper.setLightmapGpuTexture(gpuTexture);
|
wrapper.setLightmapGpuTexture(gpuTexture);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static @Nullable IClientLevelWrapper getLightmapClientLevelWrapper()
|
@Override
|
||||||
|
public float getShade(EDhDirection lodDirection)
|
||||||
{
|
{
|
||||||
IClientLevelWrapper clientLevel = ClientApi.RENDER_STATE.clientLevelWrapper;
|
EDhApiLodShading lodShading = Config.Client.Advanced.Graphics.Quality.lodShading.get();
|
||||||
if (clientLevel == null)
|
switch (lodShading)
|
||||||
{
|
{
|
||||||
clientLevel = MC_CLIENT.getWrappedClientLevel();
|
default:
|
||||||
|
case AUTO:
|
||||||
|
if (MC.level != null)
|
||||||
|
{
|
||||||
|
Direction mcDir = McObjectConverter.Convert(lodDirection);
|
||||||
|
#if MC_VER <= MC_1_21_11
|
||||||
|
return MC.level.getShade(mcDir, true);
|
||||||
|
#else
|
||||||
|
return MC.level.cardinalLighting().byFace(mcDir);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ENABLED:
|
||||||
|
switch (lodDirection)
|
||||||
|
{
|
||||||
|
case DOWN:
|
||||||
|
return 0.5F;
|
||||||
|
default:
|
||||||
|
case UP:
|
||||||
|
return 1.0F;
|
||||||
|
case NORTH:
|
||||||
|
case SOUTH:
|
||||||
|
return 0.8F;
|
||||||
|
case WEST:
|
||||||
|
case EAST:
|
||||||
|
return 0.6F;
|
||||||
|
}
|
||||||
|
|
||||||
|
case DISABLED:
|
||||||
|
return 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientLevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-66
@@ -1,32 +1,9 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
#else
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
#else
|
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_19_2
|
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
#elif MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
||||||
@@ -62,9 +39,7 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
|||||||
throw new IllegalStateException("Trying to get Installation Direction before dedicated server completed initialization!");
|
throw new IllegalStateException("Trying to get Installation Direction before dedicated server completed initialization!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_1
|
||||||
return this.dedicatedServer.getDataDirectory();
|
|
||||||
#elif MC_VER < MC_1_21_1
|
|
||||||
return this.dedicatedServer.getServerDirectory();
|
return this.dedicatedServer.getServerDirectory();
|
||||||
#else
|
#else
|
||||||
return this.dedicatedServer.getServerDirectory().toFile();
|
return this.dedicatedServer.getServerDirectory().toFile();
|
||||||
@@ -79,49 +54,9 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
|||||||
throw new IllegalStateException("Trying to get player count before dedicated server completed initialization!");
|
throw new IllegalStateException("Trying to get player count before dedicated server completed initialization!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.dedicatedServer.getCurrentPlayerCount();
|
|
||||||
#else
|
|
||||||
return this.dedicatedServer.getPlayerCount();
|
return this.dedicatedServer.getPlayerCount();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IServerLevelWrapper getWrappedServerLevel(String levelKey)
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
int dimensionID;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dimensionID = Integer.parseInt(levelKey.substring(levelKey.indexOf(":")+1));
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ignored)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#if MC_VER <= MC_1_21_10
|
|
||||||
ResourceLocation levelID = ResourceLocation.tryParse(levelKey);
|
|
||||||
#else
|
|
||||||
Identifier levelID = Identifier.tryParse(levelKey);
|
|
||||||
#endif
|
|
||||||
if (levelID == null) return null;
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_19_2
|
|
||||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registries.DIMENSION, levelID);
|
|
||||||
#else
|
|
||||||
ResourceKey<Level> resourceKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, levelID);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
ServerLevel level = dedicatedServer.getLevel(resourceKey);
|
|
||||||
#else
|
|
||||||
WorldServer level = dedicatedServer.getWorld(dimensionID);
|
|
||||||
#endif
|
|
||||||
return ServerLevelWrapper.getWrapper(level);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-42
@@ -21,50 +21,25 @@ package com.seibel.distanthorizons.common.wrappers.minecraft;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
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;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
#endif
|
|
||||||
|
|
||||||
public class ProfilerWrapper implements IProfilerWrapper
|
public class ProfilerWrapper implements IProfilerWrapper
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public Profiler profiler;
|
|
||||||
#else
|
|
||||||
public ProfilerFiller profiler;
|
public ProfilerFiller profiler;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public ProfilerWrapper(Profiler newProfiler)
|
|
||||||
#else
|
|
||||||
public ProfilerWrapper(ProfilerFiller newProfiler)
|
|
||||||
#endif
|
|
||||||
{ this.profiler = newProfiler; }
|
|
||||||
|
|
||||||
|
|
||||||
|
public ProfilerWrapper(ProfilerFiller newProfiler) { this.profiler = newProfiler; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IProfileBlock push(String newSection)
|
public IProfileBlock push(String newSection)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.profiler.startSection(newSection);
|
|
||||||
#else
|
|
||||||
this.profiler.push(newSection);
|
this.profiler.push(newSection);
|
||||||
#endif
|
|
||||||
return new ProfileBlock(this.profiler);
|
return new ProfileBlock(this.profiler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void popPush(String newSection)
|
public void popPush(String newSection)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
this.profiler.popPush(newSection);
|
||||||
this.profiler.endStartSection(newSection);
|
|
||||||
#else
|
|
||||||
this.profiler.popPush(newSection) ;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,27 +51,14 @@ public class ProfilerWrapper implements IProfilerWrapper
|
|||||||
|
|
||||||
public static class ProfileBlock implements IProfileBlock
|
public static class ProfileBlock implements IProfileBlock
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
private final ProfilerFiller profiler;
|
||||||
public Profiler profiler;
|
public ProfileBlock(ProfilerFiller newProfiler) { this.profiler = newProfiler; }
|
||||||
#else
|
|
||||||
public ProfilerFiller profiler;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public ProfileBlock(Profiler newProfiler)
|
|
||||||
#else
|
|
||||||
public ProfileBlock(ProfilerFiller newProfiler)
|
|
||||||
#endif
|
|
||||||
{ this.profiler = newProfiler; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.profiler.endSection();
|
|
||||||
#else
|
|
||||||
this.profiler.pop();
|
this.profiler.pop();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-9
@@ -1,21 +1,12 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
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;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
#endif
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface IMixinServerPlayer
|
public interface IMixinServerPlayer
|
||||||
{
|
{
|
||||||
@Nullable
|
@Nullable
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
WorldServer distantHorizons$getDimensionChangeDestination();
|
|
||||||
#else
|
|
||||||
ServerLevel distantHorizons$getDimensionChangeDestination();
|
ServerLevel distantHorizons$getDimensionChangeDestination();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER == MC_1_16_5
|
#if MC_VER == MC_1_16_5
|
||||||
void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination);
|
void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination);
|
||||||
|
|||||||
+1
-7
@@ -19,13 +19,9 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
import com.mojang.blaze3d.platform.NativeImage;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
@@ -62,6 +58,7 @@ public class LightMapWrapper implements ILightMapWrapper
|
|||||||
private final BlazeTextureViewWrapper lightmapTextureWrapper = new BlazeTextureViewWrapper();
|
private final BlazeTextureViewWrapper lightmapTextureWrapper = new BlazeTextureViewWrapper();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
// constructors //
|
// constructors //
|
||||||
//==============//
|
//==============//
|
||||||
@@ -78,7 +75,6 @@ public class LightMapWrapper implements ILightMapWrapper
|
|||||||
//==================//
|
//==================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public void uploadLightmap(NativeImage image)
|
public void uploadLightmap(NativeImage image)
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_3
|
#if MC_VER < MC_1_21_3
|
||||||
@@ -114,7 +110,6 @@ public class LightMapWrapper implements ILightMapWrapper
|
|||||||
throw new UnsupportedOperationException("setLightmapId should be used for MC versions after 1.21.3");
|
throw new UnsupportedOperationException("setLightmapId should be used for MC versions after 1.21.3");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
public void setLightmapId(int minecraftLightmapTextureId)
|
public void setLightmapId(int minecraftLightmapTextureId)
|
||||||
{
|
{
|
||||||
@@ -131,7 +126,6 @@ public class LightMapWrapper implements ILightMapWrapper
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-12
@@ -1,11 +1,7 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper;
|
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;
|
import net.minecraft.core.BlockPos;
|
||||||
#endif
|
|
||||||
|
|
||||||
public class MutableBlockPosWrapper implements IMutableBlockPosWrapper
|
public class MutableBlockPosWrapper implements IMutableBlockPosWrapper
|
||||||
{
|
{
|
||||||
@@ -16,27 +12,19 @@ public class MutableBlockPosWrapper implements IMutableBlockPosWrapper
|
|||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
//region
|
|
||||||
|
|
||||||
public MutableBlockPosWrapper()
|
public MutableBlockPosWrapper()
|
||||||
{
|
{
|
||||||
this.pos = new BlockPos.MutableBlockPos();
|
this.pos = new BlockPos.MutableBlockPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===========//
|
//===========//
|
||||||
// overrides //
|
// overrides //
|
||||||
//===========//
|
//===========//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getWrappedMcObject() { return this.pos; }
|
public Object getWrappedMcObject() { return this.pos; }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-78
@@ -6,114 +6,53 @@ import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
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.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
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,
|
* This wrapper transparently ensures that the underlying {@link ServerPlayer} is always valid,
|
||||||
* unless the player has disconnected.
|
* unless the player has disconnected.
|
||||||
*/
|
*/
|
||||||
#endif
|
|
||||||
public class ServerPlayerWrapper implements IServerPlayerWrapper
|
public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final ConcurrentMap<NetHandlerPlayServer, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
|
||||||
#else
|
|
||||||
private static final ConcurrentMap<ServerGamePacketListenerImpl, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
private static final ConcurrentMap<ServerGamePacketListenerImpl, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final NetHandlerPlayServer connection;
|
|
||||||
#else
|
|
||||||
private final ServerGamePacketListenerImpl connection;
|
private final ServerGamePacketListenerImpl connection;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public static ServerPlayerWrapper getWrapper(EntityPlayerMP serverPlayer)
|
|
||||||
#else
|
|
||||||
public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer)
|
public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer)
|
||||||
#endif
|
|
||||||
{ return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection)); }
|
{ return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection)); }
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
private ServerPlayerWrapper(ServerGamePacketListenerImpl connection) { this.connection = connection; }
|
||||||
private ServerPlayerWrapper(NetHandlerPlayServer connection)
|
|
||||||
#else
|
|
||||||
private ServerPlayerWrapper(ServerGamePacketListenerImpl connection)
|
|
||||||
#endif
|
|
||||||
{ this.connection = connection; }
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=========//
|
//=========//
|
||||||
// getters //
|
// getters //
|
||||||
//=========//
|
//=========//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
private ServerPlayer getServerPlayer() { return this.connection.player; }
|
||||||
private EntityPlayerMP getServerPlayer()
|
|
||||||
#else
|
|
||||||
private ServerPlayer getServerPlayer()
|
|
||||||
#endif
|
|
||||||
{ return this.connection.player; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName() { return this.getServerPlayer().getName().getString(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.getServerPlayer().getName();
|
|
||||||
#else
|
|
||||||
return this.getServerPlayer().getName().getString();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IServerLevelWrapper getLevel()
|
public IServerLevelWrapper getLevel()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
ServerLevel level = ((IMixinServerPlayer) this.getServerPlayer()).distantHorizons$getDimensionChangeDestination();
|
||||||
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 (level == null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
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();
|
level = this.getServerPlayer().getLevel();
|
||||||
#elif MC_VER < MC_1_21_6
|
#elif MC_VER < MC_1_21_6
|
||||||
level = this.getServerPlayer().serverLevel();
|
level = this.getServerPlayer().serverLevel();
|
||||||
@@ -128,23 +67,15 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
|||||||
@Override
|
@Override
|
||||||
public Vec3d getPosition()
|
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();
|
Vec3 position = this.getServerPlayer().position();
|
||||||
return new Vec3d(position.x, position.y, position.z);
|
return new Vec3d(position.x, position.y, position.z);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// base overrides //
|
// base overrides //
|
||||||
//================//
|
//================//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getWrappedMcObject() { return this.getServerPlayer(); }
|
public Object getWrappedMcObject() { return this.getServerPlayer(); }
|
||||||
@@ -170,8 +101,4 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() { return Objects.hashCode(this.connection); }
|
public int hashCode() { return Objects.hashCode(this.connection); }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-144
@@ -1,144 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Distant Horizons mod
|
|
||||||
* licensed under the GNU LGPL v3 License.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 James Seibel
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.modAccessor;
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.google.common.base.Suppliers;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ImmersivePortalsAbstractAccessor;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
|
||||||
import net.minecraft.client.renderer.culling.Frustum;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_19_2
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
#else
|
|
||||||
import com.mojang.math.Matrix4f;
|
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER < MC_1_17_1
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public abstract class ImmersivePortalsAccessorCommon extends ImmersivePortalsAbstractAccessor
|
|
||||||
{
|
|
||||||
// We don't use the fields in RenderStates because they are not volatile.
|
|
||||||
@Nullable
|
|
||||||
public static volatile ClientLevel originalLevel;
|
|
||||||
@Nullable
|
|
||||||
public static volatile DhBlockPos originalBlockPos;
|
|
||||||
@Nullable
|
|
||||||
public static volatile DhChunkPos originalChunkPos;
|
|
||||||
@Nullable
|
|
||||||
public static volatile Vec3d originalCameraPos;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object getClientLevel() { return Minecraft.getInstance().level; }
|
|
||||||
@Override
|
|
||||||
protected Class<?> getLevelClass() { return Level.class; }
|
|
||||||
@Override
|
|
||||||
protected Iterable<?> getEntitiesForRendering() { return Minecraft.getInstance().level.entitiesForRendering(); }
|
|
||||||
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
private static Matrix4f getProjectionMatrix()
|
|
||||||
{
|
|
||||||
#if MC_VER > MC_1_16_5
|
|
||||||
return RenderSystem.getProjectionMatrix();
|
|
||||||
#else
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Class<?> renderStates = Class.forName("com.qouteall.immersive_portals.render.context_management.RenderStates");
|
|
||||||
Field projectionMatrix = renderStates.getField("projectionMatrix");
|
|
||||||
return (Matrix4f) projectionMatrix.get(null);
|
|
||||||
}
|
|
||||||
catch (Throwable e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_19_2
|
|
||||||
protected abstract Matrix4f convert(Mat4f matrix);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Supplier<?> getFrustumSupplier()
|
|
||||||
{
|
|
||||||
#if MC_VER < MC_1_21_6 // TODO Fix this for 1.21.6+ when a more modern version of Immersive Portals is available.
|
|
||||||
return Suppliers.memoize(() -> {
|
|
||||||
Frustum frustum = new Frustum(
|
|
||||||
#if MC_VER > MC_1_19_2
|
|
||||||
ClientApi.RENDER_STATE.mcModelViewMatrix.createJomlMatrix(),
|
|
||||||
#else
|
|
||||||
convert(ClientApi.RENDER_STATE.mcModelViewMatrix),
|
|
||||||
#endif
|
|
||||||
getProjectionMatrix()
|
|
||||||
);
|
|
||||||
|
|
||||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
|
||||||
frustum.prepare(cameraPos.x, cameraPos.y, cameraPos.z);
|
|
||||||
|
|
||||||
return frustum;
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
return null;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public DhBlockPos getOriginalPlayerBlockPos() {
|
|
||||||
return originalBlockPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public DhChunkPos getOriginalPlayerChunkPos() {
|
|
||||||
return originalChunkPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public IClientLevelWrapper getOriginalClientLevelWrapper() {
|
|
||||||
return ClientLevelWrapper.getWrapper(originalLevel, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public Vec3d getOriginalCameraPos() {
|
|
||||||
return originalCameraPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+27
-251
@@ -1,48 +1,31 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.world;
|
package com.seibel.distanthorizons.common.wrappers.world;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
|
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
||||||
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCache;
|
import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCache;
|
||||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.level.KeyedClientLevelManager;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
|
||||||
import com.seibel.distanthorizons.core.level.*;
|
import com.seibel.distanthorizons.core.level.*;
|
||||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
||||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
import com.seibel.distanthorizons.core.world.AbstractDhWorld;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
#else
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -50,20 +33,19 @@ import java.awt.*;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.*;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_20_4
|
||||||
#elif MC_VER <= MC_1_20_4
|
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_3
|
||||||
#elif MC_VER < MC_1_21_3
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
#else
|
#else
|
||||||
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
@@ -83,42 +65,22 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
* where, upon world closure, some levels aren't shutdown/removed properly
|
* where, upon world closure, some levels aren't shutdown/removed properly
|
||||||
* and/or for servers were the level object isn't consistent
|
* and/or for servers were the level object isn't consistent
|
||||||
*/
|
*/
|
||||||
private static final Map<
|
private static final Map<ClientLevel, WeakReference<ClientLevelWrapper>> LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL = Collections.synchronizedMap(new WeakHashMap<>());
|
||||||
#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif,
|
|
||||||
WeakReference<ClientLevelWrapper>> 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 IKeyedClientLevelManager KEYED_CLIENT_LEVEL_MANAGER = SingletonInjector.INSTANCE.get(IKeyedClientLevelManager.class);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private static final Minecraft MINECRAFT = Minecraft.getMinecraft();
|
|
||||||
#else
|
|
||||||
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
||||||
#endif
|
|
||||||
|
|
||||||
private static final Timer CLIENT_CLEANUP_TIMER = TimerUtil.CreateTimer("ClientLevelTickCleanup");
|
|
||||||
private static final TimerTask CLIENT_CLEANUP_TASK = TimerUtil.createTimerTask(ClientLevelWrapper::tickCleanup);
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final WorldClient level;
|
|
||||||
private final ConcurrentHashMap<IBlockState, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
|
||||||
#else
|
|
||||||
private final ClientLevel level;
|
private final ClientLevel level;
|
||||||
private final ConcurrentHashMap<BlockState, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<BlockState, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/** cached method reference to reduce GC overhead */
|
/** cached method reference to reduce GC overhead */
|
||||||
private final Function<
|
private final Function<BlockState, ClientBlockStateColorCache> createCachedBlockColorCacheFunc = (blockState) -> new ClientBlockStateColorCache(blockState, this);
|
||||||
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif,
|
|
||||||
ClientBlockStateColorCache> createCachedBlockColorCacheFunc
|
|
||||||
= (blockState) -> new ClientBlockStateColorCache(blockState, this);
|
|
||||||
|
|
||||||
|
|
||||||
private boolean cloudColorFailLogged = false;
|
private boolean cloudColorFailLogged = false;
|
||||||
|
|
||||||
private volatile BlockStateWrapper dirtBlockWrapper;
|
private BlockStateWrapper dirtBlockWrapper;
|
||||||
private volatile IDhLevel dhLevel;
|
private IDhLevel dhLevel;
|
||||||
private volatile long lastAccessTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -127,7 +89,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
//=============//
|
//=============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
protected ClientLevelWrapper(#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level) { this.level = level; }
|
protected ClientLevelWrapper(ClientLevel level) { this.level = level; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
@@ -138,102 +100,16 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
//==================//
|
//==================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void markAccessed() { this.lastAccessTime = System.currentTimeMillis(); }
|
|
||||||
public synchronized long getLastAccessTime() { return this.lastAccessTime; }
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
// 20 ticks per second (50ms interval)
|
|
||||||
CLIENT_CLEANUP_TIMER.scheduleAtFixedRate(CLIENT_CLEANUP_TASK, 0, 1000 / 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void unload()
|
|
||||||
{
|
|
||||||
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
|
|
||||||
if (world == null || !world.unloadLevel(this))
|
|
||||||
{
|
|
||||||
this.onUnload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static #if MC_VER > MC_1_12_2 ClientLevel #else WorldClient #endif clientLevel() {
|
|
||||||
return #if MC_VER > MC_1_12_2 MINECRAFT.level #else MINECRAFT.world #endif;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void tickCleanup()
|
|
||||||
{
|
|
||||||
if (clientLevel() == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
|
||||||
long timeout = 30 * 1000;
|
|
||||||
|
|
||||||
ArrayList<ClientLevelWrapper> toUnload = new ArrayList<>();
|
|
||||||
synchronized(LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL)
|
|
||||||
{
|
|
||||||
for (WeakReference<ClientLevelWrapper> ref : LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL.values())
|
|
||||||
{
|
|
||||||
ClientLevelWrapper wrapper = ref.get();
|
|
||||||
if (wrapper != null
|
|
||||||
&& wrapper.level != clientLevel())
|
|
||||||
{
|
|
||||||
// We use the synchronized getter to prevent race conditions with markAccessed()
|
|
||||||
if (currentTime - wrapper.getLastAccessTime() > timeout)
|
|
||||||
{
|
|
||||||
toUnload.add(wrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ClientLevelWrapper wrapper : toUnload)
|
|
||||||
{
|
|
||||||
// Re-verify all conditions inside a synchronized block on the wrapper
|
|
||||||
// to ensure atomicity with respect to markAccessed()
|
|
||||||
synchronized(wrapper)
|
|
||||||
{
|
|
||||||
if (wrapper.level != clientLevel()
|
|
||||||
&& currentTime - wrapper.getLastAccessTime() > timeout)
|
|
||||||
{
|
|
||||||
LOGGER.debug("Unloading level [" + wrapper.getDhIdentifier() + "] due to inactivity");
|
|
||||||
wrapper.unload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* can be used when speed is important and the same level is likely to be passed in,
|
* can be used when speed is important and the same level is likely to be passed in,
|
||||||
* IE rendering.
|
* IE rendering.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static IClientLevelWrapper getWrapperIfDifferent(
|
public static IClientLevelWrapper getWrapperIfDifferent(@Nullable IClientLevelWrapper levelWrapper, @NotNull ClientLevel level)
|
||||||
@Nullable IClientLevelWrapper levelWrapper,
|
|
||||||
@NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level)
|
|
||||||
{
|
{
|
||||||
if (KEYED_CLIENT_LEVEL_MANAGER.isEnabled())
|
if (KEYED_CLIENT_LEVEL_MANAGER.isEnabled() && KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel() != levelWrapper)
|
||||||
{
|
{
|
||||||
IServerKeyedClientLevel keyedLevel = null;
|
return getWrapper(level);
|
||||||
if (KEYED_CLIENT_LEVEL_MANAGER instanceof KeyedClientLevelManager)
|
|
||||||
{
|
|
||||||
keyedLevel = ((KeyedClientLevelManager) KEYED_CLIENT_LEVEL_MANAGER).getServerKeyedLevel(level);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// FIXME: If the implementation is not KeyedClientLevelManager,
|
|
||||||
// this fallback may return the key for the wrong dimension in multiverse scenarios.
|
|
||||||
keyedLevel = KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyedLevel != levelWrapper)
|
|
||||||
{
|
|
||||||
return getWrapper(level);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientLevelWrapper clientLevelWrapper = (ClientLevelWrapper)levelWrapper;
|
ClientLevelWrapper clientLevelWrapper = (ClientLevelWrapper)levelWrapper;
|
||||||
@@ -247,13 +123,10 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static IClientLevelWrapper getWrapper(
|
public static IClientLevelWrapper getWrapper(@NotNull ClientLevel level) { return getWrapper(level, false); }
|
||||||
@NotNull #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level)
|
|
||||||
{ return getWrapper(level, false); }
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static IClientLevelWrapper getWrapper(
|
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level, boolean bypassLevelKeyManager)
|
||||||
@Nullable #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, boolean bypassLevelKeyManager)
|
|
||||||
{
|
{
|
||||||
if (!bypassLevelKeyManager)
|
if (!bypassLevelKeyManager)
|
||||||
{
|
{
|
||||||
@@ -263,31 +136,9 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// used if the client is connected to a server that defines the currently loaded level
|
// used if the client is connected to a server that defines the currently loaded level
|
||||||
IServerKeyedClientLevel overrideLevel = null;
|
IServerKeyedClientLevel overrideLevel = KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel();
|
||||||
if (KEYED_CLIENT_LEVEL_MANAGER instanceof KeyedClientLevelManager)
|
|
||||||
{
|
|
||||||
overrideLevel = ((KeyedClientLevelManager) KEYED_CLIENT_LEVEL_MANAGER).getServerKeyedLevel(level);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// FIXME: If the implementation is not KeyedClientLevelManager,
|
|
||||||
// this fallback may return the key for the wrong dimension in multiverse scenarios.
|
|
||||||
overrideLevel = KEYED_CLIENT_LEVEL_MANAGER.getServerKeyedLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (overrideLevel != null)
|
if (overrideLevel != null)
|
||||||
{
|
{
|
||||||
WeakReference<ClientLevelWrapper> levelRef = LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL.get(level);
|
|
||||||
if (levelRef != null && levelRef.get() != overrideLevel)
|
|
||||||
{
|
|
||||||
ClientLevelWrapper l = levelRef.get();
|
|
||||||
if (l != null) l.unload();
|
|
||||||
levelRef = null;
|
|
||||||
}
|
|
||||||
if (levelRef == null && overrideLevel instanceof ClientLevelWrapper)
|
|
||||||
{
|
|
||||||
LEVEL_WRAPPER_REF_BY_CLIENT_LEVEL.put(level, new WeakReference<>((ClientLevelWrapper) overrideLevel));
|
|
||||||
}
|
|
||||||
return overrideLevel;
|
return overrideLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,27 +177,19 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// this method only makes sense if we are running a single-player server
|
// this method only makes sense if we are running a single-player server
|
||||||
if (MINECRAFT.#if MC_VER <= MC_1_12_2 getIntegratedServer() #else getSingleplayerServer() #endif == null)
|
if (MINECRAFT.getSingleplayerServer() == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
WorldServer[] serverLevels = MINECRAFT.getIntegratedServer().worlds;
|
|
||||||
#else
|
|
||||||
Iterable<ServerLevel> serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels();
|
Iterable<ServerLevel> serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels();
|
||||||
#endif
|
|
||||||
|
|
||||||
// attempt to find the server level with the same dimension type
|
// 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
|
// Note: this assumes only one level per dimension type, multiverse servers may not behave correctly
|
||||||
ServerLevelWrapper foundLevelWrapper = null;
|
ServerLevelWrapper foundLevelWrapper = null;
|
||||||
for (#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif serverLevel : serverLevels)
|
for (ServerLevel serverLevel : serverLevels)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
if (serverLevel.provider.getDimension() == this.level.provider.getDimension())
|
|
||||||
#else
|
|
||||||
if (serverLevel.dimension() == this.level.dimension())
|
if (serverLevel.dimension() == this.level.dimension())
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
foundLevelWrapper = ServerLevelWrapper.getWrapper(serverLevel);
|
foundLevelWrapper = ServerLevelWrapper.getWrapper(serverLevel);
|
||||||
break;
|
break;
|
||||||
@@ -419,9 +262,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
return this.dimensionTypeWrapper;
|
return this.dimensionTypeWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.provider.getDimensionType());
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType());
|
this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType());
|
||||||
#else
|
#else
|
||||||
this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType(), this.getDimensionName());
|
this.dimensionTypeWrapper = DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType(), this.getDimensionName());
|
||||||
@@ -440,9 +281,8 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
return this.dimensionName;
|
return this.dimensionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.dimensionName = this.level.provider.getDimensionType().getName() + ":" + this.level.provider.getDimension();
|
#if MC_VER <= MC_1_21_10
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
this.dimensionName = this.level.dimension().location().toString();
|
this.dimensionName = this.level.dimension().location().toString();
|
||||||
#else
|
#else
|
||||||
this.dimensionName = this.level.dimension().identifier().toString();
|
this.dimensionName = this.level.dimension().identifier().toString();
|
||||||
@@ -451,14 +291,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getHashedSeed()
|
public long getHashedSeed() { return this.level.getBiomeManager().biomeZoomSeed; }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.level.getSeed();
|
|
||||||
#else
|
|
||||||
return this.level.getBiomeManager().biomeZoomSeed;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDhIdentifier() { return this.getHashedSeedEncoded() + "@" + this.getDimensionName(); }
|
public String getDhIdentifier() { return this.getHashedSeedEncoded() + "@" + this.getDimensionName(); }
|
||||||
@@ -466,7 +299,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
@Override
|
@Override
|
||||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; }
|
public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; }
|
||||||
|
|
||||||
public #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif getLevel() { return this.level; }
|
public ClientLevel getLevel() { return this.level; }
|
||||||
|
|
||||||
private Boolean dimHasCeiling = null;
|
private Boolean dimHasCeiling = null;
|
||||||
@Override
|
@Override
|
||||||
@@ -479,12 +312,8 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
return this.dimHasCeiling;
|
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();
|
this.dimHasCeiling = this.level.dimensionType().hasCeiling();
|
||||||
#endif
|
|
||||||
return this.dimHasCeiling;
|
return this.dimHasCeiling;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,11 +328,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
return this.dimHasSkyLight;
|
return this.dimHasSkyLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.dimHasSkyLight = this.level.provider.hasSkyLight();
|
|
||||||
#else
|
|
||||||
this.dimHasSkyLight = this.level.dimensionType().hasSkyLight();
|
this.dimHasSkyLight = this.level.dimensionType().hasSkyLight();
|
||||||
#endif
|
|
||||||
return this.dimHasSkyLight;
|
return this.dimHasSkyLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +370,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public #if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif getWrappedMcObject() { return this.level; }
|
public ClientLevel getWrappedMcObject() { return this.level; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnload()
|
public void onUnload()
|
||||||
@@ -594,20 +419,10 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
public Color getCloudColor(float tickDelta)
|
public Color getCloudColor(float tickDelta)
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_3
|
#if MC_VER < MC_1_21_3
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Vec3d colorVec3 = null;
|
|
||||||
#else
|
|
||||||
Vec3 colorVec3 = null;
|
Vec3 colorVec3 = null;
|
||||||
#endif
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
colorVec3 = this.level.getCloudColour(tickDelta);
|
|
||||||
#else
|
|
||||||
colorVec3 = this.level.getCloudColor(tickDelta);
|
colorVec3 = this.level.getCloudColor(tickDelta);
|
||||||
#endif
|
|
||||||
|
|
||||||
return new Color((float)colorVec3.x, (float)colorVec3.y, (float)colorVec3.z);
|
return new Color((float)colorVec3.x, (float)colorVec3.y, (float)colorVec3.z);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -669,45 +484,6 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getShade(EDhDirection lodDirection)
|
|
||||||
{
|
|
||||||
EDhApiLodShading lodShading = Config.Client.Advanced.Graphics.Quality.lodShading.get();
|
|
||||||
switch (lodShading)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case AUTO:
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
// 1.12.2 level doesn't have a getShade method, fall through to ENABLED
|
|
||||||
#else
|
|
||||||
Direction mcDir = McObjectConverter.Convert(lodDirection);
|
|
||||||
#if MC_VER <= MC_1_21_11
|
|
||||||
return this.level.getShade(mcDir, true);
|
|
||||||
#else
|
|
||||||
return this.level.cardinalLighting().byFace(mcDir);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
case ENABLED:
|
|
||||||
switch (lodDirection)
|
|
||||||
{
|
|
||||||
case DOWN:
|
|
||||||
return 0.5F;
|
|
||||||
default:
|
|
||||||
case UP:
|
|
||||||
return 1.0F;
|
|
||||||
case NORTH:
|
|
||||||
case SOUTH:
|
|
||||||
return 0.8F;
|
|
||||||
case WEST:
|
|
||||||
case EAST:
|
|
||||||
return 0.6F;
|
|
||||||
}
|
|
||||||
|
|
||||||
case DISABLED:
|
|
||||||
return 1.0F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-34
@@ -24,11 +24,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
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;
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
#endif
|
|
||||||
|
|
||||||
public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
||||||
{
|
{
|
||||||
@@ -90,9 +86,7 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
|||||||
}
|
}
|
||||||
private static String determineName(DimensionType dimensionType)
|
private static String determineName(DimensionType dimensionType)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_16_5
|
||||||
return dimensionType.getName();
|
|
||||||
#elif MC_VER <= MC_1_16_5
|
|
||||||
// effectsLocation() is marked as client only, so using the backing field directly
|
// effectsLocation() is marked as client only, so using the backing field directly
|
||||||
return dimensionType.effectsLocation.getPath();
|
return dimensionType.effectsLocation.getPath();
|
||||||
#elif MC_VER <= MC_1_21_10
|
#elif MC_VER <= MC_1_21_10
|
||||||
@@ -114,26 +108,10 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
|||||||
public String getName() { return this.name; }
|
public String getName() { return this.name; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCeiling()
|
public boolean hasCeiling() { return this.dimensionType.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
|
@Override
|
||||||
public boolean hasSkyLight()
|
public boolean hasSkyLight() { return this.dimensionType.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
|
@Override
|
||||||
public Object getWrappedMcObject() { return this.dimensionType; }
|
public Object getWrappedMcObject() { return this.dimensionType; }
|
||||||
@@ -142,15 +120,7 @@ public class DimensionTypeWrapper implements IDimensionTypeWrapper
|
|||||||
public boolean isTheEnd() { return this.getName().equalsIgnoreCase("the_end"); }
|
public boolean isTheEnd() { return this.getName().equalsIgnoreCase("the_end"); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getCoordinateScale()
|
public double getCoordinateScale() { return this.dimensionType.coordinateScale(); }
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+14
-49
@@ -38,17 +38,12 @@ import com.seibel.distanthorizons.core.world.EWorldEnvironment;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
#else
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ChunkSource;
|
import net.minecraft.world.level.chunk.ChunkSource;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_20_4
|
||||||
#elif MC_VER <= MC_1_20_4
|
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||||
@@ -64,9 +59,9 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
* weak references are to prevent rare issues
|
* weak references are to prevent rare issues
|
||||||
* where, upon world closure, some levels aren't shutdown/removed properly
|
* where, upon world closure, some levels aren't shutdown/removed properly
|
||||||
*/
|
*/
|
||||||
private static final Map<#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif, WeakReference<ServerLevelWrapper>> LEVEL_WRAPPER_REF_BY_SERVER_LEVEL = Collections.synchronizedMap(new WeakHashMap<>());
|
private static final Map<ServerLevel, WeakReference<ServerLevelWrapper>> LEVEL_WRAPPER_REF_BY_SERVER_LEVEL = Collections.synchronizedMap(new WeakHashMap<>());
|
||||||
|
|
||||||
private final #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level;
|
private final ServerLevel level;
|
||||||
private IDhLevel dhLevel;
|
private IDhLevel dhLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +76,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
// constructors //
|
// constructors //
|
||||||
//==============//
|
//==============//
|
||||||
|
|
||||||
public static ServerLevelWrapper getWrapper(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level)
|
public static ServerLevelWrapper getWrapper(ServerLevel level)
|
||||||
{
|
{
|
||||||
return LEVEL_WRAPPER_REF_BY_SERVER_LEVEL.compute(level, (newLevel, levelRef) ->
|
return LEVEL_WRAPPER_REF_BY_SERVER_LEVEL.compute(level, (newLevel, levelRef) ->
|
||||||
{
|
{
|
||||||
@@ -98,7 +93,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
}).get();
|
}).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerLevelWrapper(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level)
|
public ServerLevelWrapper(ServerLevel level)
|
||||||
{
|
{
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.KeyedLevelDimensionName = this.createKeyedLevelDimensionName();
|
this.KeyedLevelDimensionName = this.createKeyedLevelDimensionName();
|
||||||
@@ -113,9 +108,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
@Override
|
@Override
|
||||||
public File getMcSaveFolder()
|
public File getMcSaveFolder()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_3
|
||||||
return new File(this.level.getChunkSaveLocation(), "data");
|
|
||||||
#elif MC_VER < MC_1_21_3
|
|
||||||
return this.level.getChunkSource().getDataStorage().dataFolder;
|
return this.level.getChunkSource().getDataStorage().dataFolder;
|
||||||
#else
|
#else
|
||||||
return this.level.getChunkSource().getDataStorage().dataFolder.toFile();
|
return this.level.getChunkSource().getDataStorage().dataFolder.toFile();
|
||||||
@@ -164,9 +157,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
{
|
{
|
||||||
// We use the overworld since it's the only dimension that is stored in the server root folder
|
// We use the overworld since it's the only dimension that is stored in the server root folder
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER >= MC_1_21_3
|
||||||
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();
|
return this.level.getServer().getLevel(Level.OVERWORLD).getChunkSource().getDataStorage().dataFolder.getParent().getFileName().toString();
|
||||||
#else // <= 1.21.3
|
#else // <= 1.21.3
|
||||||
return this.level.getServer().getLevel(Level.OVERWORLD).getChunkSource().getDataStorage().dataFolder.getParentFile().getName();
|
return this.level.getServer().getLevel(Level.OVERWORLD).getChunkSource().getDataStorage().dataFolder.getParentFile().getName();
|
||||||
@@ -183,9 +174,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
@Override
|
@Override
|
||||||
public DimensionTypeWrapper getDimensionType()
|
public DimensionTypeWrapper getDimensionType()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.provider.getDimensionType());
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType());
|
return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType());
|
||||||
#else
|
#else
|
||||||
return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType(), this.getDimensionName());
|
return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType(), this.getDimensionName());
|
||||||
@@ -195,9 +184,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
@Override
|
@Override
|
||||||
public String getDimensionName()
|
public String getDimensionName()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
return this.level.provider.getDimensionType().getName() + ":" + this.level.provider.getDimension();
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
return this.level.dimension().location().toString();
|
return this.level.dimension().location().toString();
|
||||||
#else
|
#else
|
||||||
return this.level.dimension().identifier().toString();
|
return this.level.dimension().identifier().toString();
|
||||||
@@ -205,14 +192,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getHashedSeed()
|
public long getHashedSeed() { return this.level.getBiomeManager().biomeZoomSeed; }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.level.getSeed();
|
|
||||||
#else
|
|
||||||
return this.level.getBiomeManager().biomeZoomSeed;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDhIdentifier() { return this.getDimensionName(); }
|
public String getDhIdentifier() { return this.getDimensionName(); }
|
||||||
@@ -220,28 +200,13 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
@Override
|
@Override
|
||||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.SERVER_LEVEL; }
|
public EDhApiLevelType getLevelType() { return EDhApiLevelType.SERVER_LEVEL; }
|
||||||
|
|
||||||
public #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif getLevel() { return this.level; }
|
public ServerLevel getLevel() { return this.level; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCeiling()
|
public boolean hasCeiling() { return this.level.dimensionType().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
|
@Override
|
||||||
public boolean hasSkyLight()
|
public boolean hasSkyLight() { return this.level.dimensionType().hasSkyLight(); }
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
return this.level.provider.hasSkyLight();
|
|
||||||
#else
|
|
||||||
return this.level.dimensionType().hasSkyLight();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxHeight() { return this.level.getHeight(); }
|
public int getMaxHeight() { return this.level.getHeight(); }
|
||||||
@@ -259,7 +224,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif getWrappedMcObject() { return this.level; }
|
public ServerLevel getWrappedMcObject() { return this.level; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnload() { LEVEL_WRAPPER_REF_BY_SERVER_LEVEL.remove(this.level); }
|
public void onUnload() { LEVEL_WRAPPER_REF_BY_SERVER_LEVEL.remove(this.level); }
|
||||||
|
|||||||
+6
-34
@@ -26,10 +26,8 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGenerat
|
|||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling.ChunkFileReader;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling.ChunkFileReader;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.*;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.*;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams;
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
import com.seibel.distanthorizons.core.api.internal.chunkUpdating.ChunkUpdateQueueManager;
|
import com.seibel.distanthorizons.core.api.internal.chunkUpdating.ChunkUpdateQueueManager;
|
||||||
@@ -59,26 +57,18 @@ import com.seibel.distanthorizons.coreapi.ModInfo;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepBiomes;
|
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.StepFeatures;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepNoise;
|
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.StepStructureReference;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepStructureStart;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepStructureStart;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepSurface;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepSurface;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
|
||||||
#else
|
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import net.minecraft.world.level.chunk.*;
|
import net.minecraft.world.level.chunk.*;
|
||||||
import net.minecraft.world.level.levelgen.DebugLevelSource;
|
import net.minecraft.world.level.levelgen.DebugLevelSource;
|
||||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_17_1
|
#if MC_VER <= MC_1_17_1
|
||||||
#elif MC_VER <= MC_1_19_2
|
#elif MC_VER <= MC_1_19_2
|
||||||
@@ -90,14 +80,12 @@ import net.minecraft.core.registries.Registries;
|
|||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#elif MC_VER <= MC_1_20_4
|
#if MC_VER <= MC_1_20_4
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||||
#endif
|
#endif
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironmentWrapper
|
public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironmentWrapper
|
||||||
{
|
{
|
||||||
@@ -134,10 +122,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
private final ChunkUpdateQueueManager updateManager;
|
private final ChunkUpdateQueueManager updateManager;
|
||||||
|
|
||||||
public final InternalServerGenerator internalServerGenerator;
|
public final InternalServerGenerator internalServerGenerator;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public final ChunkFileReader chunkFileReader;
|
public final ChunkFileReader chunkFileReader;
|
||||||
#endif
|
|
||||||
|
|
||||||
private final Timer chunkSaveIgnoreTimer = TimerUtil.CreateTimer("ChunkSaveIgnoreTimer");
|
private final Timer chunkSaveIgnoreTimer = TimerUtil.CreateTimer("ChunkSaveIgnoreTimer");
|
||||||
|
|
||||||
@@ -146,14 +131,12 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
public final LinkedBlockingQueue<GenerationEvent> generationEventQueue = new LinkedBlockingQueue<>();
|
public final LinkedBlockingQueue<GenerationEvent> generationEventQueue = new LinkedBlockingQueue<>();
|
||||||
public final GlobalWorldGenParams globalParams;
|
public final GlobalWorldGenParams globalParams;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public final StepStructureStart stepStructureStart = new StepStructureStart(this);
|
public final StepStructureStart stepStructureStart = new StepStructureStart(this);
|
||||||
public final StepStructureReference stepStructureReference = new StepStructureReference(this);
|
public final StepStructureReference stepStructureReference = new StepStructureReference(this);
|
||||||
public final StepBiomes stepBiomes = new StepBiomes(this);
|
public final StepBiomes stepBiomes = new StepBiomes(this);
|
||||||
public final StepNoise stepNoise = new StepNoise(this);
|
public final StepNoise stepNoise = new StepNoise(this);
|
||||||
public final StepSurface stepSurface = new StepSurface(this);
|
public final StepSurface stepSurface = new StepSurface(this);
|
||||||
public final StepFeatures stepFeatures = new StepFeatures(this);
|
public final StepFeatures stepFeatures = new StepFeatures(this);
|
||||||
#endif
|
|
||||||
|
|
||||||
public boolean unsafeThreadingRecorded = false;
|
public boolean unsafeThreadingRecorded = false;
|
||||||
public boolean generatedChunkWithoutBiomeWarningLogged = false;
|
public boolean generatedChunkWithoutBiomeWarningLogged = false;
|
||||||
@@ -198,8 +181,6 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper());
|
this.updateManager = WorldChunkUpdateManager.INSTANCE.getByLevelWrapper(this.dhServerLevel.getServerLevelWrapper());
|
||||||
this.globalParams = new GlobalWorldGenParams(dhServerLevel);
|
this.globalParams = new GlobalWorldGenParams(dhServerLevel);
|
||||||
this.internalServerGenerator = new InternalServerGenerator(this.globalParams, this.dhServerLevel);
|
this.internalServerGenerator = new InternalServerGenerator(this.globalParams, this.dhServerLevel);
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.chunkFileReader = new ChunkFileReader(this.globalParams);
|
this.chunkFileReader = new ChunkFileReader(this.globalParams);
|
||||||
|
|
||||||
ChunkGenerator generator = ((ServerLevelWrapper) (dhServerLevel.getServerLevelWrapper())).getLevel().getChunkSource().getGenerator();
|
ChunkGenerator generator = ((ServerLevelWrapper) (dhServerLevel.getServerLevelWrapper())).getLevel().getChunkSource().getGenerator();
|
||||||
@@ -220,7 +201,6 @@ 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 + "].");
|
LOGGER.warn("If it does crash, disable Distant Generation or set the Generation Mode to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,11 +309,6 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
// variable setup //
|
// variable setup //
|
||||||
//================//
|
//================//
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
// MC 1.12 can only run world gen on the main thread
|
|
||||||
this.internalServerGenerator.generateChunksViaInternalServer(genEvent);
|
|
||||||
|
|
||||||
#else
|
|
||||||
int borderSize = MAX_WORLD_GEN_CHUNK_BORDER_NEEDED;
|
int borderSize = MAX_WORLD_GEN_CHUNK_BORDER_NEEDED;
|
||||||
// genEvent.size - 1 converts the even width size to an odd number for MC compatability
|
// genEvent.size - 1 converts the even width size to an odd number for MC compatability
|
||||||
int refSize = (genEvent.widthInChunks - 1) + (borderSize * 2);
|
int refSize = (genEvent.widthInChunks - 1) + (borderSize * 2);
|
||||||
@@ -583,14 +558,12 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
{
|
{
|
||||||
LOGGER.error("Unexpected error during world gen for min chunk pos ["+genEvent.minPos+"], error: ["+e.getMessage()+"].", e);
|
LOGGER.error("Unexpected error during world gen for min chunk pos ["+genEvent.minPos+"], error: ["+e.getMessage()+"].", e);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// direct generation //
|
// direct generation //
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public void generateDirect(
|
public void generateDirect(
|
||||||
GenerationEvent genEvent, ArrayGridList<ChunkWrapper> chunkWrappersToGenerate,
|
GenerationEvent genEvent, ArrayGridList<ChunkWrapper> chunkWrappersToGenerate,
|
||||||
DhLitWorldGenRegion region) throws InterruptedException
|
DhLitWorldGenRegion region) throws InterruptedException
|
||||||
@@ -755,7 +728,7 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
}
|
}
|
||||||
private static <T> ArrayGridList<T> GetCutoutFrom(ArrayGridList<T> total, int border) { return new ArrayGridList<>(total, border, total.gridSize - border); }
|
private static <T> ArrayGridList<T> GetCutoutFrom(ArrayGridList<T> total, int border) { return new ArrayGridList<>(total, border, total.gridSize - border); }
|
||||||
private static <T> ArrayGridList<T> GetCutoutFrom(ArrayGridList<T> total, EDhApiWorldGenerationStep step) { return GetCutoutFrom(total, WORLD_GEN_CHUNK_BORDER_NEEDED_BY_GEN_STEP.get(step)); }
|
private static <T> ArrayGridList<T> GetCutoutFrom(ArrayGridList<T> total, EDhApiWorldGenerationStep step) { return GetCutoutFrom(total, WORLD_GEN_CHUNK_BORDER_NEEDED_BY_GEN_STEP.get(step)); }
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// queue task //
|
// queue task //
|
||||||
@@ -796,9 +769,8 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.chunkFileReader.close();
|
this.chunkFileReader.close();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -826,12 +798,12 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
// helper classes //
|
// helper classes //
|
||||||
//================//
|
//================//
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface IEmptyChunkRetrievalFunc
|
public interface IEmptyChunkRetrievalFunc
|
||||||
{
|
{
|
||||||
ChunkAccess getChunk(int chunkPosX, int chunkPosZ);
|
ChunkAccess getChunk(int chunkPosX, int chunkPosZ);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-4
@@ -1,10 +1,6 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration;
|
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;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
#endif
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
|
|||||||
-6
@@ -25,9 +25,7 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.ThreadWorldGenParams;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.ThreadWorldGenParams;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
@@ -45,9 +43,7 @@ public final class GenerationEvent
|
|||||||
/** can be used for troubleshooting */
|
/** can be used for troubleshooting */
|
||||||
public final int id;
|
public final int id;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public final ThreadWorldGenParams threadedParam;
|
public final ThreadWorldGenParams threadedParam;
|
||||||
#endif
|
|
||||||
public final DhChunkPos minPos;
|
public final DhChunkPos minPos;
|
||||||
public final int widthInChunks;
|
public final int widthInChunks;
|
||||||
public final EDhApiWorldGenerationStep targetGenerationStep;
|
public final EDhApiWorldGenerationStep targetGenerationStep;
|
||||||
@@ -71,9 +67,7 @@ public final class GenerationEvent
|
|||||||
this.widthInChunks = widthInChunks;
|
this.widthInChunks = widthInChunks;
|
||||||
this.targetGenerationStep = targetGenerationStep;
|
this.targetGenerationStep = targetGenerationStep;
|
||||||
this.generatorMode = generatorMode;
|
this.generatorMode = generatorMode;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.threadedParam = ThreadWorldGenParams.getOrMake(generationGroup.globalParams);
|
this.threadedParam = ThreadWorldGenParams.getOrMake(generationGroup.globalParams);
|
||||||
#endif
|
|
||||||
this.future = new CompletableFuture<>();
|
this.future = new CompletableFuture<>();
|
||||||
this.resultConsumer = resultConsumer;
|
this.resultConsumer = resultConsumer;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-115
@@ -15,7 +15,6 @@ import com.seibel.distanthorizons.core.generation.DhLightingEngine;
|
|||||||
import com.seibel.distanthorizons.core.level.IDhServerLevel;
|
import com.seibel.distanthorizons.core.level.IDhServerLevel;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
|
||||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||||
@@ -24,23 +23,14 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IC2meAccess
|
|||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.util.math.ChunkPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraft.world.chunk.Chunk;
|
|
||||||
import net.minecraft.world.gen.ChunkProviderServer;
|
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
|
||||||
#else
|
|
||||||
import net.minecraft.server.level.ChunkHolder;
|
import net.minecraft.server.level.ChunkHolder;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.TicketType;
|
import net.minecraft.server.level.TicketType;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_20_4
|
||||||
#elif MC_VER <= MC_1_20_4
|
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||||
@@ -74,8 +64,7 @@ public class InternalServerGenerator
|
|||||||
*/
|
*/
|
||||||
private static final int MS_TO_IGNORE_CHUNK_AFTER_COMPLETION = 5_000;
|
private static final int MS_TO_IGNORE_CHUNK_AFTER_COMPLETION = 5_000;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_5
|
||||||
#elif MC_VER < MC_1_21_5
|
|
||||||
private static final TicketType<ChunkPos> DH_SERVER_GEN_TICKET = TicketType.create("dh_server_gen_ticket", Comparator.comparingLong(ChunkPos::toLong));
|
private static final TicketType<ChunkPos> DH_SERVER_GEN_TICKET = TicketType.create("dh_server_gen_ticket", Comparator.comparingLong(ChunkPos::toLong));
|
||||||
#elif MC_VER < MC_1_21_9
|
#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);
|
private static final TicketType DH_SERVER_GEN_TICKET = new TicketType(/* timeout, 0 = disabled*/0L, /* persist */ false, TicketType.TicketUse.LOADING);
|
||||||
@@ -121,25 +110,14 @@ public class InternalServerGenerator
|
|||||||
// create gen requests //
|
// create gen requests //
|
||||||
//=====================//
|
//=====================//
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ArrayList<CompletableFuture<Chunk>> getChunkFutureList = new ArrayList<>();
|
|
||||||
#else
|
|
||||||
ArrayList<CompletableFuture<ChunkAccess>> getChunkFutureList = new ArrayList<>();
|
ArrayList<CompletableFuture<ChunkAccess>> getChunkFutureList = new ArrayList<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
||||||
while (chunkPosIterator.hasNext())
|
while (chunkPosIterator.hasNext())
|
||||||
{
|
{
|
||||||
ChunkPos chunkPos = chunkPosIterator.next();
|
ChunkPos chunkPos = chunkPosIterator.next();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
CompletableFuture<ChunkAccess> requestChunkFuture =
|
||||||
CompletableFuture<Chunk> requestChunkFuture;
|
|
||||||
#else
|
|
||||||
CompletableFuture<ChunkAccess> requestChunkFuture;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
requestChunkFuture =
|
|
||||||
this.requestChunkFromServerAsync(chunkPos)
|
this.requestChunkFromServerAsync(chunkPos)
|
||||||
// log errors if necessary
|
// log errors if necessary
|
||||||
.whenCompleteAsync(
|
.whenCompleteAsync(
|
||||||
@@ -182,16 +160,8 @@ public class InternalServerGenerator
|
|||||||
ArrayList<IChunkWrapper> chunkWrappers = new ArrayList<>();
|
ArrayList<IChunkWrapper> chunkWrappers = new ArrayList<>();
|
||||||
for (int i = 0; i < getChunkFutureList.size(); i++)
|
for (int i = 0; i < getChunkFutureList.size(); i++)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
CompletableFuture<ChunkAccess> getChunkFuture = getChunkFutureList.get(i);
|
||||||
CompletableFuture<Chunk> getChunkFuture;
|
ChunkAccess chunk = getChunkFuture.join();
|
||||||
Chunk chunk;
|
|
||||||
#else
|
|
||||||
CompletableFuture<ChunkAccess> getChunkFuture;
|
|
||||||
ChunkAccess chunk;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
getChunkFuture = getChunkFutureList.get(i);
|
|
||||||
chunk = getChunkFuture.join();
|
|
||||||
if (chunk != null)
|
if (chunk != null)
|
||||||
{
|
{
|
||||||
ChunkWrapper chunkWrapper = new ChunkWrapper(chunk, this.dhServerLevel.getLevelWrapper());
|
ChunkWrapper chunkWrapper = new ChunkWrapper(chunk, this.dhServerLevel.getLevelWrapper());
|
||||||
@@ -275,47 +245,8 @@ public class InternalServerGenerator
|
|||||||
LOGGER.warn(c2meWarning);
|
LOGGER.warn(c2meWarning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private CompletableFuture<Chunk> requestChunkFromServerAsync(ChunkPos chunkPos)
|
|
||||||
#else
|
|
||||||
private CompletableFuture<ChunkAccess> requestChunkFromServerAsync(ChunkPos chunkPos)
|
private CompletableFuture<ChunkAccess> requestChunkFromServerAsync(ChunkPos chunkPos)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
WorldServer level = this.params.mcServerLevel;
|
|
||||||
|
|
||||||
// ignore chunk update events for this position
|
|
||||||
if (this.updateManager != null)
|
|
||||||
{
|
|
||||||
this.updateManager.addPosToIgnore(McObjectConverter.Convert(chunkPos));
|
|
||||||
}
|
|
||||||
|
|
||||||
CompletableFuture<Chunk> future = new CompletableFuture<>();
|
|
||||||
level.getMinecraftServer().addScheduledTask(() ->
|
|
||||||
{
|
|
||||||
ChunkProviderServer provider = level.getChunkProvider();
|
|
||||||
|
|
||||||
// load neighbors 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 (this.updateManager != null)
|
|
||||||
{
|
|
||||||
this.updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x + i, chunkPos.z + j));
|
|
||||||
}
|
|
||||||
provider.provideChunk(chunkPos.x + i, chunkPos.z + j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Chunk chunk = provider.provideChunk(chunkPos.x, chunkPos.z);
|
|
||||||
future.complete(chunk);
|
|
||||||
});
|
|
||||||
return future;
|
|
||||||
#else
|
|
||||||
return CompletableFuture.supplyAsync(() ->
|
return CompletableFuture.supplyAsync(() ->
|
||||||
{
|
{
|
||||||
ServerLevel level = this.params.mcServerLevel;
|
ServerLevel level = this.params.mcServerLevel;
|
||||||
@@ -358,65 +289,27 @@ public class InternalServerGenerator
|
|||||||
|
|
||||||
}, this.params.mcServerLevel.getChunkSource().chunkMap.mainThreadExecutor)
|
}, this.params.mcServerLevel.getChunkSource().chunkMap.mainThreadExecutor)
|
||||||
.thenCompose(Function.identity());
|
.thenCompose(Function.identity());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* mitigates out of memory issues in the vanilla chunk system. <br>
|
* mitigates out of memory issues in the vanilla chunk system. <br>
|
||||||
* See: https://github.com/pop4959/Chunky/pull/383
|
* See: https://github.com/pop4959/Chunky/pull/383
|
||||||
*/
|
*/
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private CompletableFuture<Void> releaseChunkFromServerAsync(WorldServer level, ChunkPos chunkPos)
|
|
||||||
#else
|
|
||||||
private CompletableFuture<Void> releaseChunkFromServerAsync(ServerLevel level, ChunkPos chunkPos)
|
private CompletableFuture<Void> releaseChunkFromServerAsync(ServerLevel level, ChunkPos chunkPos)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
CompletableFuture<Void> removeTicketFuture = new CompletableFuture<>();
|
CompletableFuture<Void> removeTicketFuture = new CompletableFuture<>();
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
level.getMinecraftServer().addScheduledTask(() ->
|
|
||||||
#else
|
|
||||||
level.getChunkSource().chunkMap.mainThreadExecutor.execute(() ->
|
level.getChunkSource().chunkMap.mainThreadExecutor.execute(() ->
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_21_5
|
||||||
for (int difX = -1; difX <= 1; difX++)
|
|
||||||
{
|
|
||||||
for (int difZ = -1; difZ <= 1; difZ++)
|
|
||||||
{
|
|
||||||
if (difX != 0 || difZ != 0)
|
|
||||||
{
|
|
||||||
final int finalDifX = difX;
|
|
||||||
final int finalDifZ = difZ;
|
|
||||||
this.chunkSaveIgnoreTimer.schedule(new TimerTask()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (InternalServerGenerator.this.updateManager != null)
|
|
||||||
{
|
|
||||||
InternalServerGenerator.this.updateManager.removePosToIgnore(
|
|
||||||
new DhChunkPos(
|
|
||||||
chunkPos.x + finalDifX,
|
|
||||||
chunkPos.z + finalDifZ
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif MC_VER < MC_1_21_5
|
|
||||||
int chunkLevel = 33; // 33 is equivalent to FULL Chunk
|
int chunkLevel = 33; // 33 is equivalent to FULL Chunk
|
||||||
level.getChunkSource().distanceManager.removeTicket(DH_SERVER_GEN_TICKET, chunkPos, chunkLevel, chunkPos);
|
level.getChunkSource().distanceManager.removeTicket(DH_SERVER_GEN_TICKET, chunkPos, chunkLevel, chunkPos);
|
||||||
#else
|
#else
|
||||||
level.getChunkSource().removeTicketWithRadius(DH_SERVER_GEN_TICKET, chunkPos, 0);
|
level.getChunkSource().removeTicketWithRadius(DH_SERVER_GEN_TICKET, chunkPos, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
level.getChunkSource().chunkMap.tick(() -> false);
|
level.getChunkSource().chunkMap.tick(() -> false);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_16_5
|
#if MC_VER > MC_1_16_5
|
||||||
level.entityManager.tick();
|
level.entityManager.tick();
|
||||||
@@ -447,6 +340,7 @@ public class InternalServerGenerator
|
|||||||
removeTicketFuture.complete(null);
|
removeTicketFuture.complete(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return removeTicketFuture;
|
return removeTicketFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-2
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling;
|
package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||||
@@ -750,4 +749,3 @@ public class ChunkCompoundTagParser
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|||||||
-2
@@ -1,6 +1,5 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling;
|
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.chunk.ChunkWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.GlobalWorldGenParams;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.RegionFileStorageExternalCache;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.RegionFileStorageExternalCache;
|
||||||
@@ -342,4 +341,3 @@ public class ChunkFileReader implements AutoCloseable
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
-2
@@ -1,6 +1,5 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling;
|
package com.seibel.distanthorizons.common.wrappers.worldGeneration.chunkFileHandling;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -147,4 +146,3 @@ public class CompoundTagUtil
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
-2
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@@ -490,4 +489,3 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
-2
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import net.minecraft.world.level.lighting.*;
|
import net.minecraft.world.level.lighting.*;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -98,4 +97,3 @@ public class DummyLightEngine extends LevelLightEngine
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
-2
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
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.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||||
|
|
||||||
@@ -81,4 +80,3 @@ public class LightGetterAdaptor implements LightChunkGetter
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
-2
@@ -1,6 +1,5 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
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.common.wrappers.worldGeneration.chunkFileHandling.ChunkFileReader;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
@@ -251,4 +250,3 @@ public class RegionFileStorageExternalCache implements AutoCloseable
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
-2
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -278,4 +277,3 @@ public class WorldGenStructFeatManager extends #if MC_VER < MC_1_19_2 StructureF
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+7
-51
@@ -19,20 +19,10 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.params;
|
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.common.wrappers.world.ServerLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.level.IDhServerLevel;
|
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.util.math.ChunkPos;
|
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraft.world.gen.IChunkGenerator;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
#else
|
|
||||||
import com.mojang.datafixers.DataFixer;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@@ -66,46 +56,30 @@ import net.minecraft.world.level.levelgen.WorldGenSettings;
|
|||||||
#else
|
#else
|
||||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
/**
|
/**
|
||||||
* Handles parameters that are relevant for the entire MC world.
|
* Handles parameters that are relevant for the entire MC world.
|
||||||
*
|
*
|
||||||
* @see ThreadWorldGenParams
|
* @see ThreadWorldGenParams
|
||||||
*/
|
*/
|
||||||
#endif
|
|
||||||
|
|
||||||
public final class GlobalWorldGenParams
|
public final class GlobalWorldGenParams
|
||||||
{
|
{
|
||||||
public final IDhServerLevel dhServerLevel;
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public final IChunkGenerator generator;
|
|
||||||
public final WorldServer mcServerLevel;
|
|
||||||
#else
|
|
||||||
public final ChunkGenerator generator;
|
public final ChunkGenerator generator;
|
||||||
|
public final IDhServerLevel dhServerLevel;
|
||||||
public final ServerLevel mcServerLevel;
|
public final ServerLevel mcServerLevel;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
public final Registry<Biome> biomes;
|
public final Registry<Biome> biomes;
|
||||||
public final RegistryAccess registry;
|
public final RegistryAccess registry;
|
||||||
#endif
|
|
||||||
|
|
||||||
public final long worldSeed;
|
public final long worldSeed;
|
||||||
public final DataFixer dataFixer;
|
public final DataFixer dataFixer;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_2
|
||||||
#elif MC_VER < MC_1_19_2
|
|
||||||
public final StructureManager structures;
|
public final StructureManager structures;
|
||||||
#else
|
#else
|
||||||
public final StructureTemplateManager structures;
|
public final StructureTemplateManager structures;
|
||||||
public final RandomState randomState;
|
public final RandomState randomState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_4
|
||||||
#elif MC_VER < MC_1_19_4
|
|
||||||
public final WorldGenSettings worldGenSettings;
|
public final WorldGenSettings worldGenSettings;
|
||||||
#else
|
#else
|
||||||
public final WorldOptions worldOptions;
|
public final WorldOptions worldOptions;
|
||||||
@@ -125,22 +99,13 @@ public final class GlobalWorldGenParams
|
|||||||
public GlobalWorldGenParams(IDhServerLevel dhServerLevel)
|
public GlobalWorldGenParams(IDhServerLevel dhServerLevel)
|
||||||
{
|
{
|
||||||
this.dhServerLevel = dhServerLevel;
|
this.dhServerLevel = dhServerLevel;
|
||||||
|
|
||||||
this.mcServerLevel = ((ServerLevelWrapper) dhServerLevel.getServerLevelWrapper()).getWrappedMcObject();
|
this.mcServerLevel = ((ServerLevelWrapper) dhServerLevel.getServerLevelWrapper()).getWrappedMcObject();
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
MinecraftServer server = this.mcServerLevel.getMinecraftServer();
|
|
||||||
#else
|
|
||||||
MinecraftServer server = this.mcServerLevel.getServer();
|
MinecraftServer server = this.mcServerLevel.getServer();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
WorldData worldData = server.getWorldData();
|
WorldData worldData = server.getWorldData();
|
||||||
this.registry = server.registryAccess();
|
this.registry = server.registryAccess();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_19_4
|
||||||
this.worldSeed = mcServerLevel.getSeed();
|
|
||||||
#elif MC_VER < MC_1_19_4
|
|
||||||
this.worldGenSettings = worldData.worldGenSettings();
|
this.worldGenSettings = worldData.worldGenSettings();
|
||||||
this.biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY);
|
this.biomes = registry.registryOrThrow(Registry.BIOME_REGISTRY);
|
||||||
this.worldSeed = worldGenSettings.seed();
|
this.worldSeed = worldGenSettings.seed();
|
||||||
@@ -158,24 +123,15 @@ public final class GlobalWorldGenParams
|
|||||||
this.worldSeed = this.worldOptions.seed();
|
this.worldSeed = this.worldOptions.seed();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_18_2
|
#if MC_VER >= MC_1_18_2
|
||||||
this.biomeManager = new BiomeManager(this.mcServerLevel, BiomeManager.obfuscateSeed(this.worldSeed));
|
this.biomeManager = new BiomeManager(this.mcServerLevel, BiomeManager.obfuscateSeed(this.worldSeed));
|
||||||
this.chunkScanner = this.mcServerLevel.getChunkSource().chunkScanner();
|
this.chunkScanner = this.mcServerLevel.getChunkSource().chunkScanner();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.generator = this.mcServerLevel.getChunkProvider().chunkGenerator;
|
|
||||||
#else
|
|
||||||
this.structures = server.getStructureManager();
|
this.structures = server.getStructureManager();
|
||||||
this.generator = this.mcServerLevel.getChunkSource().getGenerator();
|
this.generator = this.mcServerLevel.getChunkSource().getGenerator();
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.dataFixer = server != null ? server.getDataFixer() : null;
|
|
||||||
#else
|
|
||||||
this.dataFixer = server.getFixerUpper();
|
this.dataFixer = server.getFixerUpper();
|
||||||
#endif
|
|
||||||
#if MC_VER >= MC_1_19_2
|
#if MC_VER >= MC_1_19_2
|
||||||
this.randomState = this.mcServerLevel.getChunkSource().randomState();
|
this.randomState = this.mcServerLevel.getChunkSource().randomState();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
-2
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.params;
|
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 com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.WorldGenStructFeatManager;
|
||||||
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@@ -120,4 +119,3 @@ public final class ThreadWorldGenParams
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
-2
@@ -1,6 +1,5 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
|
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.chunk.ChunkWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.ThreadWorldGenParams;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.params.ThreadWorldGenParams;
|
||||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||||
@@ -53,4 +52,3 @@ public abstract class AbstractWorldGenStep
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user