1.12.2 working in dev

This commit is contained in:
Vojtěch Šokala
2026-03-11 09:20:32 +01:00
parent 1d0d67d215
commit c5adc3f72a
128 changed files with 5096 additions and 502 deletions
+18 -2
View File
@@ -12,10 +12,10 @@ buildscript {
configurations.configureEach {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == "org.apache.commons" && details.requested.name == "commons-compress") {
details.useVersion("1.28.0")
details.because("Needed because of Cleanroom. net.minecraftforge:DiffPatch:2.0.7 from dev.architectury.loom pulls ancient commons-compress 1.18")
}
}
}
}
@@ -33,7 +33,9 @@ plugins {
id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha"
// Architectury is used here only as a replacement for forge's own loom
id "dev.architectury.loom" version "1.13-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.0-SNAPSHOT" apply false
id 'xyz.wagyourtail.unimined' version '1.4.10-kappa' apply false
}
/**
@@ -160,6 +162,20 @@ subprojects { p ->
apply plugin: "com.github.johnrengelman.shadow"
if (isMinecraftSubProject)
apply plugin: "systems.manifold.manifold-gradle-plugin"
if (rootProject.minecraft_version == "1.12.2" && p == project(":common")) {
p.afterEvaluate {
def cleanroomProject = project(":cleanroom")
cleanroomProject.afterEvaluate {
p.dependencies {
compileOnly p.files(cleanroomProject.configurations.minecraftLibraries.files)
compileOnly p.files(cleanroomProject.configurations.forgeRuntimeLibrary.files)
compileOnly p.files(cleanroomProject.configurations.minecraft.files)
}
}
}
}
// Apply forge's loom
if ((findProject(":forge") && p == project(":forge")) ||
+55 -15
View File
@@ -3,8 +3,8 @@ plugins {
id 'java-library'
id 'maven-publish'
id 'com.gradleup.shadow' version '9.2.2'
id 'xyz.wagyourtail.unimined' version '1.4.9-kappa'
id 'net.kyori.blossom' version '2.1.0'
id 'xyz.wagyourtail.unimined' version '1.4.10-kappa'
id 'net.kyori.blossom' version '2.1.0'
}
apply from: 'gradle/scripts/helpers.gradle'
@@ -56,7 +56,11 @@ unimined.minecraft {
}
cleanroom {
loader "0.3.31-alpha"
//propertyBool('use_access_transformer')
if (true) {
accessTransformer "${rootProject.projectDir}/cleanroom/src/main/resources/1_12_2_distanthorizons_at.cfg"
}
loader "0.4.4-alpha"
runs.auth.username = "Developer"
runs.all {
systemProperty("crl.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json")
@@ -64,15 +68,47 @@ unimined.minecraft {
if (extraArgs != null && !extraArgs.trim().isEmpty()) {
jvmArgs += extraArgs.split { "\\s+" }.toList()
}
if (propertyBool('enable_foundation_debug')) {
println "Classpath size BEFORE: ${classpath.files.size()}"
classpath = classpath.filter { file ->
def remove =
file.path.contains("DistantHorizons-common") ||
file.path.contains("DistantHorizons-core") ||
file.path.contains("DistantHorizons-api")
if (remove) {
println "Removing from classpath: $file"
}
return !remove
}
println "Classpath size AFTER: ${classpath.files.size()}"
def extraPath = [
sourceSets.main.output.classesDirs.asPath,
sourceSets.main.output.resourcesDir.absolutePath,
rootProject.project(':common').sourceSets.main.output.classesDirs.asPath,
rootProject.project(':core').sourceSets.main.output.classesDirs.asPath,
rootProject.project(':api').sourceSets.main.output.classesDirs.asPath,
].join(File.pathSeparator)
jvmArgs -= ("-Dcrl.dev.extrapath=")
jvmArgs += ("-Dcrl.dev.extrapath=${extraPath}")
if (false) {
systemProperty("foundation.dump", "true")
systemProperty("foundation.verbose", "true")
}
//propertyBool('is_coremod')
if (true) {
//coremod_plugin_class_name
systemProperty("fml.coreMods.load", propertyString('com.seibel.distanthorizons.forge.DistantHorizonsLoadingPlugin'))
//forge for now bcs it will crash but correct is .cleanroom
systemProperty("fml.coreMods.load", "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin")
}
return
}
}
@@ -104,11 +140,7 @@ unimined.minecraft {
}
dependencies {
//propertyBool('enable_junit_testing')
if (true) {
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
compileOnly "com.cleanroommc:sponge-mixin:0.20.12+mixin.0.8.7"
}
processResources {
@@ -167,6 +199,13 @@ jar {
}
}
doFirst {
archiveClassifier = 'dev'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
if (configurations.contain.size() > 0) {
into('/') {
from configurations.contain
}
}
manifest {
def attribute_map = [:]
attribute_map['ModType'] = "CRL"
@@ -178,14 +217,15 @@ jar {
//propertyBool('is_coremod')
if (true) {
//coremod_plugin_class_name
attribute_map['FMLCorePlugin'] = propertyString('com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin')
attribute_map['FMLCorePlugin'] = "com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin"
//coremod_includes_mod
if (true) {
attribute_map['FMLCorePluginContainsFMLMod'] = true
}
}
if (propertyBool('use_access_transformer')) {
attribute_map['FMLAT'] = propertyString('access_transformer_locations')
//propertyBool('use_access_transformer')
if (true) {
attribute_map['FMLAT'] = "1_12_2_distanthorizons_at.cfg"
}
attributes(attribute_map)
}
@@ -197,7 +237,6 @@ jar {
}
}
shadowJar {
configurations = [project.configurations.shadow]
archiveClassifier = "shadow"
@@ -221,7 +260,8 @@ test {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
})
if (propertyBool('show_testing_output')) {
//propertyBool('show_testing_output')
if (false) {
testLogging {
showStandardStreams = true
}
@@ -0,0 +1,245 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <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.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL32;
import java.util.concurrent.AbstractExecutorService;
/**
* This handles all events sent to the client,
* and is the starting point for most of the mod.
*
* @author James_Seibel
* @version 2023-7-27
*/
public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy
{
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final CleanroomPluginPacketSender PACKET_SENDER = (CleanroomPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class);
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static World GetEventLevel(WorldEvent e) { return e.getWorld(); }
@Override
public void registerEvents()
{
MinecraftForge.EVENT_BUS.register(this);
// handles singleplayer, LAN, and connecting to a server
PACKET_SENDER.setPacketHandler((IServerPlayerWrapper player, @NotNull AbstractNetworkMessage message) ->
{
ClientApi.INSTANCE.pluginMessageReceived(message);
ServerApi.INSTANCE.pluginMessageReceived(player, message);
});
}
//==============//
// world events //
//==============//
@SubscribeEvent
public void clientLevelLoadEvent(WorldEvent.Load event)
{
LOGGER.info("level load");
World level = event.getWorld();
if (!(level instanceof WorldClient clientLevel))
{
return;
}
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
}
@SubscribeEvent
public void clientLevelUnloadEvent(WorldEvent.Unload event)
{
LOGGER.info("level unload");
World level = event.getWorld();
if (!(level instanceof WorldClient clientLevel))
{
return;
}
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
ClientApi.INSTANCE.clientLevelUnloadEvent(clientLevelWrapper);
}
//==============//
// chunk events //
//==============//
@SubscribeEvent
public void rightClickBlockEvent(PlayerInteractEvent.RightClickBlock event)
{
if (MC.clientConnectedToDedicatedServer())
{
World level = event.getWorld();
ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(level);
if (SharedApi.isChunkAtBlockPosAlreadyUpdating(wrappedLevel, event.getPos().getX(), event.getPos().getZ()))
{
return;
}
AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null)
{
executor.execute(() ->
{
Chunk chunk = level.getChunk(event.getPos());
SharedApi.INSTANCE.applyChunkUpdate(new ChunkWrapper(chunk, wrappedLevel), wrappedLevel);
});
}
}
}
@SubscribeEvent
public void leftClickBlockEvent(PlayerInteractEvent.LeftClickBlock event)
{
if (MC.clientConnectedToDedicatedServer())
{
World level = event.getWorld();
ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(level);
if (SharedApi.isChunkAtBlockPosAlreadyUpdating(wrappedLevel, event.getPos().getX(), event.getPos().getZ()))
{
return;
}
AbstractExecutorService executor = ThreadPoolUtil.getFileHandlerExecutor();
if (executor != null)
{
executor.execute(() ->
{
Chunk chunk = level.getChunk(event.getPos());
SharedApi.INSTANCE.applyChunkUpdate(new ChunkWrapper(chunk, wrappedLevel), wrappedLevel);
});
}
}
}
@SubscribeEvent
public void clientChunkLoadEvent(ChunkEvent.Load event)
{
if (MC.clientConnectedToDedicatedServer())
{
ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(GetEventLevel(event));
IChunkWrapper chunkWrapper = new ChunkWrapper(event.getChunk(), wrappedLevel);
SharedApi.INSTANCE.applyChunkUpdate(chunkWrapper, wrappedLevel);
}
}
//==============//
// key bindings //
//==============//
@SubscribeEvent
public void registerKeyBindings(InputEvent.KeyInputEvent event)
{
/* if (Minecraft.getMinecraft().player == null)
{
return;
}
if (event.getAction() != GLFW.GLFW_PRESS)
{
return;
}
ClientApi.INSTANCE.keyPressedEvent(event.getKey());*/
}
//===========//
// rendering //
//===========//
@SubscribeEvent
public void afterLevelRenderEvent(TickEvent.RenderTickEvent event)
{
if (event.type.equals(TickEvent.RenderTickEvent.Type.RENDER))
{
try
{
// should generally only need to be set once per game session
// allows DH to render directly to Optifine's level frame buffer,
// allowing better shader support
MinecraftRenderWrapper.INSTANCE.finalLevelFrameBufferId = GL32.glGetInteger(GL32.GL_FRAMEBUFFER_BINDING);
}
catch (Exception | Error e)
{
LOGGER.error("Unexpected error in afterLevelRenderEvent: "+e.getMessage(), e);
}
}
}
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent.Text event) {
Minecraft mc = Minecraft.getMinecraft();
if (event.isCanceled() || !mc.gameSettings.showDebugInfo) return;
F3Screen.addStringToDisplay(event.getRight());
}
}
@@ -0,0 +1,129 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <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.core.api.internal.ServerApi;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
import com.seibel.distanthorizons.coreapi.ModInfo;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import java.util.function.Consumer;
/**
* Initialize and setup the Mod. <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 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 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();
}
}
@@ -0,0 +1,96 @@
package com.seibel.distanthorizons.cleanroom;
import com.seibel.distanthorizons.common.AbstractPluginPacketSender;
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
import com.seibel.distanthorizons.core.network.messages.MessageRegistry;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class CleanroomPluginPacketSender extends AbstractPluginPacketSender
{
public static final SimpleNetworkWrapper PLUGIN_CHANNEL =
NetworkRegistry.INSTANCE.newSimpleChannel(
AbstractPluginPacketSender.WRAPPER_PACKET_RESOURCE
);
public static void setPacketHandler(Consumer<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);
}
// Forge doesn't support using abstract classes
@SuppressWarnings({"ClassCanBeRecord", "RedundantSuppression"})
public static class MessageWrapper implements IMessage
{
public AbstractNetworkMessage message;
public MessageWrapper(AbstractNetworkMessage message) { this.message = message; }
public MessageWrapper()
{
// For reflection
}
@Override
public void fromBytes(ByteBuf buf) {
int messageId = buf.readByte();
message = MessageRegistry.INSTANCE.createMessage(messageId);
message.decode(buf);
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeByte(MessageRegistry.INSTANCE.getMessageId(message));
message.encode(buf);
}
public static class Handler implements IMessageHandler<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
}
}
}
}
@@ -0,0 +1,149 @@
package com.seibel.distanthorizons.cleanroom;
import com.seibel.distanthorizons.common.AbstractModInitializer;
import com.seibel.distanthorizons.common.util.ProxyUtil;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.InternalServerGenerator;
import com.seibel.distanthorizons.core.api.internal.ServerApi;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import java.lang.reflect.Field;
public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy
{
private static final CleanroomPluginPacketSender PACKET_SENDER = (CleanroomPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class);
private static World GetEventLevel(WorldEvent e) { return e.getWorld(); }
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private final ServerApi serverApi = ServerApi.INSTANCE;
private final boolean isDedicated;
@Override
public void registerEvents()
{
MinecraftForge.EVENT_BUS.register(this);
if (this.isDedicated)
{
PACKET_SENDER.setPacketHandler(ServerApi.INSTANCE::pluginMessageReceived);
}
}
//=============//
// constructor //
//=============//
public CleanroomServerProxy(boolean isDedicated) { this.isDedicated = isDedicated; }
//========//
// events //
//========//
// ServerLevelLoadEvent
@SubscribeEvent
public void serverLevelLoadEvent(WorldEvent.Load event)
{
if (GetEventLevel(event) instanceof WorldServer)
{
this.serverApi.serverLevelLoadEvent(getServerLevelWrapper((WorldServer) GetEventLevel(event)));
InternalServerGenerator.DH_SERVER_GEN_TICKET = ForgeChunkManager.requestTicket(CleanroomMain.instance, event.getWorld(), ForgeChunkManager.Type.NORMAL);
//increase chunk limit
try
{
Field maxDepthField = InternalServerGenerator.DH_SERVER_GEN_TICKET.getClass().getDeclaredField("maxDepth");
maxDepthField.setAccessible(true);
maxDepthField.setInt(InternalServerGenerator.DH_SERVER_GEN_TICKET, 1000);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
// ServerLevelUnloadEvent
@SubscribeEvent
public void serverLevelUnloadEvent(WorldEvent.Unload event)
{
if (GetEventLevel(event) instanceof WorldServer)
{
this.serverApi.serverLevelUnloadEvent(getServerLevelWrapper((WorldServer) GetEventLevel(event)));
}
}
@SubscribeEvent
public void serverChunkLoadEvent(ChunkEvent.Load event)
{
ILevelWrapper levelWrapper = ProxyUtil.getLevelWrapper(GetEventLevel(event));
IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), levelWrapper);
this.serverApi.serverChunkLoadEvent(chunk, levelWrapper);
}
@SubscribeEvent
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
{ this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); }
@SubscribeEvent
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
{ this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event)); }
@SubscribeEvent
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
{
this.serverApi.serverPlayerLevelChangeEvent(
getServerPlayerWrapper(event),
getServerLevelWrapper(event.fromDim, event),
getServerLevelWrapper(event.toDim, event)
);
}
//================//
// helper methods //
//================//
private static ServerLevelWrapper getServerLevelWrapper(WorldServer level) { return ServerLevelWrapper.getWrapper(level); }
private static ServerLevelWrapper getServerLevelWrapper(int dimensionId, PlayerEvent event)
{
MinecraftServer server = event.player.getServer();
if (server == null)
{
LOGGER.error("getServerLevelWrapper: server is null for player {}", event.player.getName());
return null;
}
return getServerLevelWrapper(server.getWorld(dimensionId));
}
private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event)
{
return ServerPlayerWrapper.getWrapper((EntityPlayerMP) event.player);
}
}
@@ -0,0 +1,37 @@
package com.seibel.distanthorizons.cleanroom;
import net.minecraftforge.fml.common.Loader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Set;
public class DistantHorizonsConfigPlugin implements IMixinConfigPlugin
{
private static final Logger LOGGER = LogManager.getLogger();
@Override
public void onLoad(String mixinPackage)
{ }
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName)
{
/* return switch (mixinClassName.split("\\.")[5]) {
case "mist" -> Loader.isModLoaded("mist");
default -> true;
};*/
return true;
}
@Override public String getRefMapperConfig() { return null; }
@Override public void acceptTargets(Set<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) { }
}
@@ -0,0 +1,33 @@
package com.seibel.distanthorizons.cleanroom;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
public class DistantHorizonsLoadingPlugin implements IFMLLoadingPlugin
{
@Override
public @Nullable String[] getASMTransformerClass()
{
return new String[0];
}
@Override
public @Nullable String getModContainerClass()
{
return null;
}
@Override
public @Nullable String getSetupClass()
{
return null;
}
@Override
public void injectData(Map<String, Object> data) { }
@Override
public @Nullable String getAccessTransformerClass()
{
return null;
}
}
@@ -0,0 +1,71 @@
package com.seibel.distanthorizons.cleanroom.mixins.client;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.init.MobEffects;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EntityRenderer.class)
public class MixinEntityRenderer
{
@Shadow
@Final
private DynamicTexture lightmapTexture;
@Shadow @Final private Minecraft mc;
@Shadow @Final private static Logger LOGGER;
private static final float A_REALLY_REALLY_BIG_VALUE = 420694206942069.F;
private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F;
@Inject(at = @At("TAIL"), method = "updateLightmap")
public void onUpdateLightmap(float patrialTicks, CallbackInfo ci)
{
IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
if (mc == null || mc.getWrappedClientLevel() == null)
{
return;
}
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel();
MinecraftRenderWrapper renderWrapper = (MinecraftRenderWrapper)SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
renderWrapper.setLightmapId(lightmapTexture.getGlTextureId(), clientLevel);
}
@Inject(at = @At("RETURN"), method = "setupFog")
private void disableSetupFog(int startCoords, float partialTicks, CallbackInfo ci)
{
boolean cameraNotInFluid = mc.getRenderViewEntity() != null && !mc.world.getBlockState(mc.getRenderViewEntity().getPosition()).getMaterial().isLiquid();
boolean isSpecialFog = mc.player.isPotionActive(MobEffects.BLINDNESS);
if (!isSpecialFog
&& cameraNotInFluid
&& startCoords == 0 // 0 = terrain fog
&& !SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class).isFogStateSpecial()
&& !Config.Client.Advanced.Graphics.Fog.enableVanillaFog.get())
{
GlStateManager.setFogStart(A_REALLY_REALLY_BIG_VALUE);
GlStateManager.setFogEnd(A_EVEN_LARGER_VALUE);
ClientApi.RENDER_STATE.vanillaFogEnabled = false;
}
else
{
ClientApi.RENDER_STATE.vanillaFogEnabled = true;
}
}
}
@@ -0,0 +1,27 @@
package com.seibel.distanthorizons.cleanroom.mixins.client;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.play.server.SPacketJoinGame;
import net.minecraft.util.text.ITextComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(NetHandlerPlayClient.class)
public class MixinNetHandlerPlayClient
{
@Inject(method = "handleJoinGame", at = @At("RETURN"))
private void onHandleJoinGameEnd(SPacketJoinGame packet, CallbackInfo ci)
{
ClientApi.INSTANCE.onClientOnlyConnected();
}
@Inject(method = "onDisconnect", at = @At("RETURN"))
private void onDisconnect(ITextComponent reason, CallbackInfo ci)
{
ClientApi.INSTANCE.onClientOnlyDisconnected();
}
}
@@ -0,0 +1,83 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <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
"DH" /* ModInfo.ID + ".title" */)));
}
@Inject(at = @At("HEAD"), method = "actionPerformed", cancellable = true)
private void lodconfig$actionPerformed(GuiButton button, CallbackInfo ci)
{
if (button.id == button_id)
{
Minecraft.getMinecraft().displayGuiScreen(GetConfigScreen.getScreen(this));
ci.cancel();
}
}
}
@@ -0,0 +1,62 @@
package com.seibel.distanthorizons.cleanroom.mixins.client;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.entity.Entity;
import net.minecraft.util.BlockRenderLayer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderGlobal.class)
public class MixinRenderGlobal
{
@Shadow private WorldClient world;
@Inject(method = "renderBlockLayer(Lnet/minecraft/util/BlockRenderLayer;DILnet/minecraft/entity/Entity;)I", at = @At("HEAD"))
private void renderChunkLayer(BlockRenderLayer blockLayerIn, double partialTicks, int pass, Entity entityIn, CallbackInfoReturnable<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);
}
}
}
@@ -0,0 +1,26 @@
package com.seibel.distanthorizons.cleanroom.mixins.common;
import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.ChunkProviderServer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ChunkProviderServer.class)
public class MixinChunkProviderServer
{
@Shadow
@Final
public WorldServer world;
@Inject(method = "saveChunkData", at = @At("RETURN"))
private void onSaveChunkData(Chunk chunk, CallbackInfo ci)
{
MixinChunkMapCommon.onChunkSave(world, chunk);
}
}
@@ -0,0 +1,49 @@
package com.seibel.distanthorizons.cleanroom.mixins.server;
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ITeleporter;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EntityPlayerMP.class)
public abstract class MixinEntityPlayerMP implements IMixinServerPlayer
{
@Shadow
@Final
public MinecraftServer server;
@Unique
@Nullable
private volatile WorldServer distantHorizons$dimensionChangeDestination;
@Override
@Nullable
public WorldServer distantHorizons$getDimensionChangeDestination()
{
return this.distantHorizons$dimensionChangeDestination;
}
@Inject(at = @At("HEAD"), method = "changeDimension(ILnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;")
public void setDimensionChangeDestination(int destinationDimensionID, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir)
{
this.distantHorizons$dimensionChangeDestination = this.server.getWorld(destinationDimensionID);
}
@Inject(at = @At("RETURN"), method = "clearInvulnerableDimensionChange")
public void clearDimensionChangeDestination(CallbackInfo ci)
{
this.distantHorizons$dimensionChangeDestination = null;
}
}
@@ -0,0 +1,52 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <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();
}
}
@@ -0,0 +1,3 @@
public net.minecraft.client.renderer.EntityRenderer getFOVModifier(FZ)F
public net.minecraft.client.renderer.ActiveRenderInfo MODELVIEW
public net.minecraft.client.renderer.ActiveRenderInfo PROJECTION
@@ -0,0 +1,647 @@
#PARSE_ESCAPES
distanthorizons.title=Distant Horizons
distanthorizons.general.true=True
distanthorizons.general.false=False
distanthorizons.general.yes=Yes
distanthorizons.general.no=No
distanthorizons.general.back=Back
distanthorizons.general.next=Next
distanthorizons.general.done=Done
distanthorizons.general.cancel=Cancel
distanthorizons.general.reset=Reset
distanthorizons.general.spacer=
distanthorizons.general.apiOverride=API LOCK
distanthorizons.general.disabledByApi.@tooltip=This option is controlled by another mod via DH's API \nso it cannot be changed via the UI or config file.
distanthorizons.updater.title=Distant Horizons auto updater
distanthorizons.updater.text1=§lNew update available!
distanthorizons.updater.text2=§fDo you want to update from %s§f to %s§f?
distanthorizons.updater.later=Not now
distanthorizons.updater.never=Don't show again
distanthorizons.updater.update=Update
distanthorizons.updater.update.@tooltip=Updates the mod this one time\n(Updates when game is closed)
distanthorizons.updater.silent=Always silent update
distanthorizons.updater.silent.@tooltip=Every time an update is available, it would update\n(§6WARNING§r: This wont prompt you when updating)
distanthorizons.updater.waitingForClose=Distant Horizons will finish updating once the game restarts
distanthorizons.config.title=Distant Horizons config
distanthorizons.config.client=Client
distanthorizons.config.client.quickEnableRendering=Enable Rendering
distanthorizons.config.client.quickEnableRendering.@tooltip=Determines if Distant Horizons Renders LODs.
distanthorizons.config.client.quickShowWorldGenProgress=Show LOD Gen/Import Progress
distanthorizons.config.client.quickShowWorldGenProgress.@tooltip=If true then the world gen/importing progress will be displayed on the screen when running.
distanthorizons.config.client.qualityPresetSetting=Quality Preset
distanthorizons.config.client.qualityPresetSetting.@tooltip=Modifies a number of graphical settings to quickly change Distant Horizons' rendering quality. \n\nLower this setting if your GPU is at max usage or you are having framerate issues.
distanthorizons.config.client.threadPresetSetting=CPU Load
distanthorizons.config.client.threadPresetSetting.@tooltip=Modifies how many threads Distant Horizons' will use. \n\nIncreasing this setting will improve the Distant Generator speed and LOD loading speed, \nbut will also increase CPU/memory usage and may introduce stuttering. \n\nNote: This is a CPU relative setting. \nIt should put an equal amount of strain on a 2 core CPU as a 64 core CPU.
distanthorizons.config.client.optionsButton=Show The Options Button
distanthorizons.config.client.optionsButton.@tooltip=Show the config button to the left of the fov button
distanthorizons.config.client.advanced=Advanced options
distanthorizons.config.client.advanced.graphics=Graphics
distanthorizons.config.client.advanced.worldGenerator=World Generator
distanthorizons.config.client.advanced.server=Server
distanthorizons.config.client.advanced.lodBuilding=LOD Building
distanthorizons.config.client.advanced.multiThreading=Multi-Threading
distanthorizons.config.client.advanced.logging=Logging
distanthorizons.config.client.advanced.graphics.quality=Quality
distanthorizons.config.client.advanced.graphics.quality.lodChunkRenderDistanceRadius=LOD Chunk Render Distance Radius
distanthorizons.config.client.advanced.graphics.quality.lodChunkRenderDistanceRadius.@tooltip=Distant Horizons' render distance, measured in chunks. \n\nNote: this is a best effort number. \nThe render distance may be above or below this number \ndepending on your other graphic settings.
distanthorizons.config.client.advanced.graphics.quality.horizontalQuality=LOD Dropoff Distance
distanthorizons.config.client.advanced.graphics.quality.horizontalQuality.@tooltip=How far apart drops in quality are.\n\nHigher settings will increase the distance between drops\nbut will increase memory and GPU usage.
distanthorizons.config.client.advanced.graphics.quality.maxHorizontalResolution=Max Horizontal Resolution
distanthorizons.config.client.advanced.graphics.quality.maxHorizontalResolution.@tooltip=The maximum detail LODs are rendered at.\n\n§6Fastest:§r Chunk\n§6Fanciest:§r Block
distanthorizons.config.client.advanced.graphics.quality.verticalQuality=Vertical Quality
distanthorizons.config.client.advanced.graphics.quality.verticalQuality.@tooltip=How well LODs represent overhangs, caves, cliffsides, etc.\n\nHigher options will increase memory and GPU usage.
distanthorizons.config.client.advanced.graphics.quality.horizontalScale=Horizontal Scale
distanthorizons.config.client.advanced.graphics.quality.horizontalScale.@tooltip=How quickly LODs drop off in quality.\n\nLarger numbers will improve how distant terrain looks\nbut will increase memory and GPU usage.
distanthorizons.config.client.advanced.graphics.quality.transparency=Transparency
distanthorizons.config.client.advanced.graphics.quality.blocksToIgnore=Blocks To Ignore
distanthorizons.config.client.advanced.graphics.quality.blocksToIgnore.@tooltip=Defines the types of blocks to ignore when generating LODs.
distanthorizons.config.client.advanced.graphics.quality.tintWithAvoidedBlocks=Tint With Avoided Blocks
distanthorizons.config.client.advanced.graphics.quality.tintWithAvoidedBlocks.@tooltip=§4Note: makes snow, carpet, and trapdoors look really bad§r\nShould the blocks underneath avoided blocks gain the color of the avoided block?\n§6True:§r a red flower on grass will tint the grass below it red\n§6False:§r skipped blocks will not change color of surface below them
distanthorizons.config.client.advanced.graphics.quality.lodShading=LOD Shading
distanthorizons.config.client.advanced.graphics.quality.lodShading.@tooltip=Defines how LODs should be shaded. \nCan be used to improve shader compatibility.
distanthorizons.config.client.advanced.graphics.quality.grassSideRendering=Grass Side Rendering
distanthorizons.config.client.advanced.graphics.quality.grassSideRendering.@tooltip=How should the sides and bottom of grass block LODs render?
distanthorizons.config.client.advanced.graphics.quality.ditherDhFade=Fade Nearby DH LODs
distanthorizons.config.client.advanced.graphics.quality.ditherDhFade.@tooltip=If true LODs will fade away as you get closer to them. \nIf false LODs will cut off abruptly at a set distance from the camera. \nThis setting is affected by the vanilla overdraw prevention config.
distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode=Vanilla Fade Mode
distanthorizons.config.client.advanced.graphics.quality.vanillaFadeMode.@tooltip=How should vanilla Minecraft fade into Distant Horizons LODs? \n\nNONE: Fastest, there will be a pronounced border between DH and MC rendering. \nSINGLE_PASS: Fades after MC's transparent pass, opaque blocks underwater won't be faded. \nDOUBLE_PASS: Slowest, fades after both MC's opaque and transparent passes, provides the smoothest transition.
distanthorizons.config.client.advanced.graphics.quality.dhFadeFarClipPlane=Fade Before Far Clip Plane
distanthorizons.config.client.advanced.graphics.quality.dhFadeFarClipPlane.@tooltip=Should DH fade out before reaching the far plane? \nThis is helpful to prevent DH clouds from cutting off in the distance.
distanthorizons.config.client.advanced.graphics.quality.brightnessMultiplier=Brightness Multiplier
distanthorizons.config.client.advanced.graphics.quality.brightnessMultiplier.@tooltip=How bright LOD colors are.\n\n0 = black \n1 = normal \n2 = near white
distanthorizons.config.client.advanced.graphics.quality.saturationMultiplier=Saturation Multiplier
distanthorizons.config.client.advanced.graphics.quality.saturationMultiplier.@tooltip=How saturated LOD colors are.\n\n0 = black and white \n1 = normal \n2 = vibrant
distanthorizons.config.client.advanced.graphics.quality.lodBiomeBlending=Biome Blending
distanthorizons.config.client.advanced.graphics.quality.lodBiomeBlending.@tooltip=This is the same as vanilla Biome Blending settings for LOD area. \n\nNote that anything other than '0' will greatly effect Lod building time\nand increase triangle count. The cost on chunk generation speed is also \nquite large if set to too high.\n\n'0' equals to Vanilla Biome Blending of '1x1', \n'1' equals to Vanilla Biome Blending of '3x3', \n'2' equals to Vanilla Biome Blending of '5x5'... \n
distanthorizons.config.client.advanced.graphics.ssao=Ambient Occlusion
distanthorizons.config.client.advanced.graphics.ssao.enableSsao=Enable Ambient Occlusion
distanthorizons.config.client.advanced.graphics.ssao.enableSsao.@tooltip=Ambient Occlusion adds depth to the lighting of blocks.
distanthorizons.config.client.advanced.graphics.ssao.sampleCount=Sample Count
distanthorizons.config.client.advanced.graphics.ssao.sampleCount.@tooltip=Determines how many points in space are sampled for the occlusion test. \nHigher numbers will improve quality and reduce banding, but will increase GPU load.
distanthorizons.config.client.advanced.graphics.ssao.radius=Radius
distanthorizons.config.client.advanced.graphics.ssao.radius.@tooltip=Determines the radius Screen Space Ambient Occlusion is applied, measured in blocks.
distanthorizons.config.client.advanced.graphics.ssao.strength=Strength
distanthorizons.config.client.advanced.graphics.ssao.strength.@tooltip=Determines how dark the Screen Space Ambient Occlusion effect will be.
distanthorizons.config.client.advanced.graphics.ssao.bias=Bias
distanthorizons.config.client.advanced.graphics.ssao.bias.@tooltip=Increasing the value can reduce banding at the cost of reducing the strength of the effect.
distanthorizons.config.client.advanced.graphics.ssao.minLight=Min Light
distanthorizons.config.client.advanced.graphics.ssao.minLight.@tooltip=Determines how dark the occlusion shadows can be. \n0 = totally black at the corners \n1 = no shadow
distanthorizons.config.client.advanced.graphics.ssao.blurRadius=Blur Radius
distanthorizons.config.client.advanced.graphics.ssao.blurRadius.@tooltip=The radius, measured in pixels, that blurring is calculated for the SSAO. \nHigher numbers will reduce banding at the cost of GPU performance.
distanthorizons.config.client.advanced.graphics.ssao.fadeDistanceInBlocks=Fade Distance
distanthorizons.config.client.advanced.graphics.ssao.fadeDistanceInBlocks.@tooltip=The distance in blocks from the camera where the SSAO will fade out to. \nThis is done to prevent banding and noise at extreme distances.
distanthorizons.config.client.advanced.graphics.genericRendering=Generic Object Rendering
distanthorizons.config.client.advanced.graphics.genericRendering.enableGenericRendering=Enable Rendering
distanthorizons.config.client.advanced.graphics.genericRendering.enableGenericRendering.@tooltip=If true non terrain objects will be rendered in DH's terrain. \nThis includes beacon beams and clouds.
distanthorizons.config.client.advanced.graphics.genericRendering.enableBeaconRendering=Enable Beacon Rendering
distanthorizons.config.client.advanced.graphics.genericRendering.beaconRenderHeight=Beacon render height
distanthorizons.config.client.advanced.graphics.genericRendering.beaconRenderHeight.@tooltip=Sets the maximum height at which beacons will render. \nThis will only affect new beacons coming into LOD render distance. \nBeacons currently visible in LOD chunks will not be affected.
distanthorizons.config.client.advanced.graphics.genericRendering.expandDistantBeacons=Expand Distant Beacons
distanthorizons.config.client.advanced.graphics.genericRendering.expandDistantBeacons.@tooltip=If true LOD beacon beams will be rendered wider at extreme distances, \nmaking them easier to see. \nIf false all LOD beacon beams will only ever be 1 block wide.
distanthorizons.config.client.advanced.graphics.genericRendering.enableBeaconRendering.@tooltip=If true LOD beacon beams will be rendered.
distanthorizons.config.client.advanced.graphics.genericRendering.enableCloudRendering=Enable Cloud Rendering
distanthorizons.config.client.advanced.graphics.genericRendering.enableCloudRendering.@tooltip=If true LOD clouds will be rendered.
distanthorizons.config.client.advanced.graphics.genericRendering.dimensionEnabledCloudRenderingCsv=Enable Cloud Rendering
distanthorizons.config.client.advanced.graphics.genericRendering.dimensionEnabledCloudRenderingCsv.@tooltip=A comma separated separated list of dimension resource locations where DH clouds will render. \n\nExample: \minecraft:overworld,minecraft:the_end\ \n\nChanges will only be seen when the world is re-loaded.
distanthorizons.config.client.advanced.graphics.genericRendering.enableUnexploredFogRendering=Enable Unexplored Fog Rendering
distanthorizons.config.client.advanced.graphics.genericRendering.enableUnexploredFogRendering.@tooltip=If true unexplored/ungenerated LODs will be rendered as large dark gray boxes.
distanthorizons.config.client.advanced.graphics.genericRendering.enableInstancedRendering=Enable Instanced Rendering
distanthorizons.config.client.advanced.graphics.genericRendering.enableInstancedRendering.@tooltip=Can be disabled to use much slower but more compatible direct rendering. \nDisabling this can be used to fix some crashes on Mac.
distanthorizons.config.client.advanced.graphics.fog=Fog
distanthorizons.config.client.advanced.graphics.fog.enableDhFog=Enable Distant Horizons Fog
distanthorizons.config.client.advanced.graphics.fog.enableDhFog.@tooltip=Determines if fog is drawn on DH LODs.
distanthorizons.config.client.advanced.graphics.fog.colorMode=Fog Color Mode
distanthorizons.config.client.advanced.graphics.fog.colorMode.@tooltip=The color of the fog on LODs.
distanthorizons.config.client.advanced.graphics.fog.enableVanillaFog=Enable Vanilla Fog
distanthorizons.config.client.advanced.graphics.fog.enableVanillaFog.@tooltip=§6True:§r Minecraft renders fog like normal.\n§6False:§r disables Minecraft's fog on vanilla chunks.\n\nMay cause issues with other mods that edit fog.
distanthorizons.config.client.advanced.graphics.fog.advancedFog=Advanced Fog Options
distanthorizons.config.client.advanced.graphics.fog.farFogStart=Fog Start
distanthorizons.config.client.advanced.graphics.fog.farFogStart.@tooltip=Where should the fog start? \n\n'0.0': Fog start at player's position.\n'1.0': The fog-start's circle fit just in the lod render distance square.\n'1.414': The lod render distance square fit just in the fog-start's circle.\n
distanthorizons.config.client.advanced.graphics.fog.farFogEnd=Fog End
distanthorizons.config.client.advanced.graphics.fog.farFogEnd.@tooltip=Where should the fog end? \n\n'0.0': Fog end at player's position.\n'1.0': The fog-end's circle fit just in the lod render distance square.\n'1.414': The lod render distance square fit just in the fog-end's circle.\n
distanthorizons.config.client.advanced.graphics.fog.farFogMin=Fog Min
distanthorizons.config.client.advanced.graphics.fog.farFogMin.@tooltip=What is the minimum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n
distanthorizons.config.client.advanced.graphics.fog.farFogMax=Fog Max
distanthorizons.config.client.advanced.graphics.fog.farFogMax.@tooltip=What is the maximum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n
distanthorizons.config.client.advanced.graphics.fog.farFogFalloff=Fog Falloff
distanthorizons.config.client.advanced.graphics.fog.farFogFalloff.@tooltip=How should the fog thickness should be calculated? \n\nLINEAR: Linear based on distance (will ignore 'density')\nEXPONENTIAL: 1/(e^(distance*density)) \nEXPONENTIAL_SQUARED: 1/(e^((distance*density)^2)) \n
distanthorizons.config.client.advanced.graphics.fog.farFogDensity=Fog Density
distanthorizons.config.client.advanced.graphics.fog.farFogDensity.@tooltip=What is the fog's density?
distanthorizons.config.client.advanced.graphics.fog.heightFog=Height Fog Options
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMixMode=Height Fog Mix Mode
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMixMode.@tooltip=Defines how height effects fog. \nWhen in doubt start with SPHERICAL, ADDITION, or MAX. \n\nSPHERICAL: Fog is calculated based on camera distance. \nCYLINDRICAL: Ignore height, fog is calculated based on horizontal distance. \nMAX: max(heightFog, farFog) \nADDITION: heightFog + farFog \nMULTIPLY: heightFog * farFog \nINVERSE_MULTIPLY: 1 - (1-heightFog) * (1-farFog) \nLIMITED_ADDITION: farFog + max(farFog, heightFog) \nMULTIPLY_ADDITION: farFog + farFog * heightFog \nINVERSE_MULTIPLY_ADDITION: farFog + 1 - (1-heightFog) * (1-farFog) \nAVERAGE: farFog*0.5 + heightFog*0.5
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDirection=Height Fog Direction
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDirection.@tooltip=Where should the height fog be located? \n\nABOVE_CAMERA: Height fog starts from camera to the sky \nBELOW_CAMERA: Height fog starts from camera to the void \nABOVE_AND_BELOW_CAMERA: Height fog starts from camera to both the sky and the void \nABOVE_SET_HEIGHT: Height fog starts from a set height to the sky \nBELOW_SET_HEIGHT: Height fog starts from a set height to the void \nABOVE_AND_BELOW_SET_HEIGHT: Height fog starts from a set height to both the sky and the void \n
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogBaseHeight=Height Fog Base Height
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogBaseHeight.@tooltip=If the height fog is calculated around a set height, what is that height position?
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogStart=Height Fog Start
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogStart.@tooltip=How far the start of height fog should offset? \n\n'0.0': Fog start with no offset.\n'1.0': Fog start with offset of the entire world's height. (Include depth)\n
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogEnd=Height Fog End
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogEnd.@tooltip=How far the end of height fog should offset? \n\n'0.0': Fog end with no offset.\n'1.0': Fog end with offset of the entire world's height. (Include depth)\n
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMin=Height Fog Min
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMin.@tooltip=What is the minimum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMax=Height Fog Max
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogMax.@tooltip=What is the maximum fog thickness? \n\n'0.0': No fog at all.\n'1.0': Fully fog color.\n
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogFalloff=Height Fog Falloff
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogFalloff.@tooltip=How should the height fog thickness should be calculated? \n\nLINEAR: Linear based on height (will ignore 'density')\nEXPONENTIAL: 1/(e^(height*density)) \nEXPONENTIAL_SQUARED: 1/(e^((height*density)^2)) \n
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDensity=Height Fog Density
distanthorizons.config.client.advanced.graphics.fog.heightFog.heightFogDensity.@tooltip=What is the height fog's density?
distanthorizons.config.client.advanced.graphics.noiseTexture=Noise Texture
distanthorizons.config.client.advanced.graphics.noiseTexture.enableNoiseTexture=Enable Noise Texture
distanthorizons.config.client.advanced.graphics.noiseTexture.enableNoiseTexture.@tooltip=If enabled a noise texture will be applied to LODs to simulate textures.
distanthorizons.config.client.advanced.graphics.noiseTexture.noiseSteps=Noise Steps
distanthorizons.config.client.advanced.graphics.noiseTexture.noiseSteps.@tooltip=Determines how many steps of noise should be applied to the LODs.
distanthorizons.config.client.advanced.graphics.noiseTexture.noiseIntensity=Noise Intensity
distanthorizons.config.client.advanced.graphics.noiseTexture.noiseIntensity.@tooltip=Determines how intense the noise texture is.
distanthorizons.config.client.advanced.graphics.noiseTexture.noiseDropoff=Noise Dropoff
distanthorizons.config.client.advanced.graphics.noiseTexture.noiseDropoff.@tooltip=Defines how far should the noise texture render before it fades away. (in blocks). \nSet to 0 to disable noise from fading away.
distanthorizons.config.client.advanced.graphics.culling=Culling
distanthorizons.config.client.advanced.graphics.culling.overdrawPrevention=Overdraw Prevention
distanthorizons.config.client.advanced.graphics.culling.overdrawPrevention.@tooltip=Determines how far from the camera Distant Horizons will start rendering. \nMeasured as a percentage of the vanilla render distance.\n-1 = Auto, overdraw will change based on the vanilla render distance.\n\nHigher values will prevent LODs from rendering behind vanilla blocks at a higher distance,\nbut may cause holes to appear in the LODs. \nHoles are most likely to appear when flying through unloaded terrain. \n\nIncreasing the vanilla render distance increases the effectiveness of this setting.
distanthorizons.config.client.advanced.graphics.culling.reduceOverdrawWithFastMovement=Reduce Overdraw With Fast Movement
distanthorizons.config.client.advanced.graphics.culling.reduceOverdrawWithFastMovement.@tooltip=If set to true the overdraw prevention radius will get closer \nto the camera when flying/moving quickly. \n\nThis helps reduce issues where Minecraft can't load or \ngenerate chunks fast enough to keep up with DH.
distanthorizons.config.client.advanced.graphics.culling.enableCaveCulling=Cave Culling
distanthorizons.config.client.advanced.graphics.culling.enableCaveCulling.@tooltip=If enabled caves will be culled \n\nAdditional Info: Currently this cull all faces \n with skylight value of 0 under the cave culling height in dimensions that \n do not have a ceiling. \n
distanthorizons.config.client.advanced.graphics.culling.caveCullingHeight=Cave Culling Height
distanthorizons.config.client.advanced.graphics.culling.caveCullingHeight.@tooltip=At what Y value should cave culling start?
distanthorizons.config.client.advanced.graphics.culling.disableBeaconDistanceCulling=Enable Beacon Distance Culling
distanthorizons.config.client.advanced.graphics.culling.disableBeaconDistanceCulling.@tooltip=If true beacons near the camera won't be drawn to prevent vanilla overdraw. \nIf false all beacons will be rendered.
distanthorizons.config.client.advanced.graphics.culling.disableFrustumCulling=Disable Frustum Culling
distanthorizons.config.client.advanced.graphics.culling.disableFrustumCulling.@tooltip=If false LODs outside the player's camera \naren't drawn, increasing GPU performance. \n\nIf true all LODs are drawn, even those behind \nthe player's camera, decreasing GPU performance. \n\nDisable this if you see LODs disappearing at the corners of your vision.
distanthorizons.config.client.advanced.graphics.culling.disableShadowPassFrustumCulling=Disable Shadow Pass Frustum Culling
distanthorizons.config.client.advanced.graphics.culling.disableShadowPassFrustumCulling.@tooltip=Identical to the other frustum culling option except that it is \nonly used when a shader mod is present using the DH API \nand the shadow pass is being rendered. \n\nDisable this if shadows render incorrectly.
distanthorizons.config.client.advanced.graphics.culling.ignoredRenderBlockCsv=Ignored Block CSV
distanthorizons.config.client.advanced.graphics.culling.ignoredRenderBlockCsv.@tooltip=A comma separated list of block resource locations that won't be rendered by DH. \nNote: air is always included in this list.
distanthorizons.config.client.advanced.graphics.culling.ignoredRenderCaveBlockCsv=Ignored Cave Block CSV
distanthorizons.config.client.advanced.graphics.culling.ignoredRenderCaveBlockCsv.@tooltip=A comma separated list of block resource locations that shouldn't be rendered \nif they are in a 0 sky light underground area. \nNote: air is always included in this list.
distanthorizons.config.client.advanced.graphics.overrideVanillaGraphicsSettings=Override Vanilla Settings
distanthorizons.config.client.advanced.graphics.overrideVanillaGraphicsSettings.@tooltip=If true some vanilla graphics settings will be automatically changed \nduring DH setup to provide a better experience. \n\nIE disabling vanilla clouds (which render on top of DH LODs), \nand chunk fading (DH already fades MC chunks).
distanthorizons.config.client.advanced.graphics.experimental=Experimental
distanthorizons.config.client.advanced.graphics.experimental.earthCurveRatio=Earth Curve Ratio
distanthorizons.config.client.advanced.graphics.experimental.earthCurveRatio.@tooltip=A value of 1 is equivalent to the curvature of Earth in real life. \nThe minimum accepted value is 50 and the maximum value is 5000. \nEverything between 1 and 49 will be rounded up to 50.
distanthorizons.config.client.advanced.graphics.experimental.ignoredDimensionCsv=Ignored Dimension CSV
distanthorizons.config.client.advanced.graphics.experimental.ignoredDimensionCsv.@tooltip=A comma separated list of dimension resource locations where DH won't render. Example: \minecraft:the_nether,minecraft:the_end\ \n\nNote: \nSome DH settings will be disabled and/or changed to improve \nvisuals when DH rendering is disabled.
distanthorizons.config.client.advanced.autoUpdater=Auto Updater
distanthorizons.config.client.advanced.autoUpdater.enableAutoUpdater=Enable automatic updates
distanthorizons.config.client.advanced.autoUpdater.enableSilentUpdates=Enable Silent Updates
distanthorizons.config.client.advanced.autoUpdater.enableSilentUpdates.@tooltip=Automatically updates the mod when an update is available
distanthorizons.config.client.advanced.autoUpdater.updateBranch=Update Branch
distanthorizons.config.client.advanced.autoUpdater.updateBranch.@tooltip=Where to download the latest update from. \n\nAuto: Downloads either stable or nightly builds based on the current jar. \nStable: Stable builds from Modrinth. \nNightly: Nightly builds from Gitlab.
distanthorizons.config.client.advanced.multiplayer=Multiplayer
distanthorizons.config.client.advanced.multiplayer.serverFolderNameMode=Server Folder Mode
distanthorizons.config.client.advanced.multiplayer.serverFolderNameMode.@tooltip=Determines the folder format for local multiplayer data.\n\n§6Name Only:§r\nUses the server browser name. Ex: \Minecraft Server\\n§6IP Only:§r\n\192.168.1.40\\n§6Name IP:§r\n\Minecraft Server, IP 192.168.1.40\\n§6Name, IP, Port:§r\n\Minecraft Server, IP 192.168.1.40:25565\\n§6Name, IP, Port, MC Version:§r\n\Minecraft Server, IP 192.168.1.40:25565, GameVersion 1.18.1\\n\n§c§lCaution:§r changing while connected to a multiplayer server may cause glitches.
distanthorizons.config.client.advanced.debugging=Debug
distanthorizons.config.client.advanced.debugging.rendererMode=Renderer Mode
distanthorizons.config.client.advanced.debugging.debugRendering=Debug Rendering
distanthorizons.config.client.advanced.debugging.lodOnlyMode=Only Render LODs
distanthorizons.config.client.advanced.debugging.lodOnlyMode.@tooltip=If enabled this will disable (most) vanilla Minecraft rendering. \n\nNOTE: Do not report any issues when this mode is on! \nThis setting is only for fun and debugging. \nMod compatibility is not guaranteed.
distanthorizons.config.client.advanced.debugging.renderWireframe=Render Wireframe
distanthorizons.config.client.advanced.debugging.renderWireframe.@tooltip=If enabled the LODs will render as wireframe.
distanthorizons.config.client.advanced.debugging.enableDebugKeybindings=Enable debug keybindings
distanthorizons.config.client.advanced.debugging.enableDebugKeybindings.@tooltip=If true several keys can be used to toggle debug states. \nF6 - enable/disable LOD rendering \nF7 - enable/disable LOD only rendering \nF8 - cycle through the different debug rendering modes
distanthorizons.config.client.advanced.debugging.enableWhiteWorld=Enable white world
distanthorizons.config.client.advanced.debugging.enableWhiteWorld.@tooltip=If enabled, vertex color will not be passed.\nUseful for debugging shaders.
distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors=Show overlapping quad errors
distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors.@tooltip=If true overlapping quads will be rendered as bright red for easy identification. \nIf false the quads will be rendered normally.
distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection=Log Buffer Garbage Collection
distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection.@tooltip=If true OpenGL Buffer garbage collection will be logged \nthis also includes the number of live buffers.
distanthorizons.config.client.advanced.debugging.allowUnsafeValues=Allow Unsafe UI Values
distanthorizons.config.client.advanced.debugging.allowUnsafeValues.@tooltip=If enabled, very limited config input validation will be performed. \n\nWarning: enabling this can cause instability or crashing, use at your own risk. \nNote: this option isn't saved between sessions.
distanthorizons.config.client.advanced.debugging.debugWireframe=Debug Wireframe
distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering=Enable Debug Wireframe Rendering
distanthorizons.config.client.advanced.debugging.debugWireframe.enableRendering.@tooltip=If enabled, various wireframes for debugging internal functions will be drawn.
distanthorizons.config.client.advanced.debugging.debugWireframe.showWorldGenQueue=Show World Gen Queue
distanthorizons.config.client.advanced.debugging.debugWireframe.showNetworkSyncOnLoadQueue=Show Network Sync On Load Queue
distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderSectionStatus=Show Render Section Status
distanthorizons.config.client.advanced.debugging.debugWireframe.showRenderSectionToggling=Show Render Section Toggling
distanthorizons.config.client.advanced.debugging.debugWireframe.showQuadTreeRenderStatus=Show Quad Tree Render Status
distanthorizons.config.client.advanced.debugging.debugWireframe.showFullDataUpdateStatus=Show Full Data Update Status
distanthorizons.config.client.advanced.debugging.openGl=Open GL
distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger=Override Vanilla GL Logger
distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger.@tooltip=Defines how OpenGL errors are handled. \nRequires rebooting Minecraft to change. \nWill catch OpenGL errors thrown by other mods.
distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce=Only Log GL Errors Once
distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce.@tooltip=If true each Open GL error will only be logged once. \nTEnabling this may cause some error logs to be missed. \nDoes nothing if overrideVanillaGLLogger is set to false. \n\nGenerally this can be kept as 'true' to prevent log spam. \nHowever, Please set this to 'false' if a developer needs your log to debug a GL issue. \n
distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode=OpenGL Error Handling Mode
distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode.@tooltip=Defines how OpenGL errors are handled. \n Requires rebooting Minecraft to apply. \nMay incorrectly catch OpenGL errors thrown by other mods.
distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering=Validate Buffer IDs Before Rendering
distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering.@tooltip=Massively reduces FPS. \nShould only be used if mysterious EXCEPTION_ACCESS_VIOLATION crashes are happening in DH's rendering code and you're attempting to troubleshoot it.
distanthorizons.config.client.advanced.debugging.openGl.glUploadMode=Uploade Mode
distanthorizons.config.client.advanced.debugging.openGl.glUploadMode.@tooltip=Only for debugging
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging=Render Column Builder
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugEnable=Enable Column Builder Limiting
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugDetailLevel=Column Builder Limit - Detail Level
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugXPos=Column Builder Limit - X Pos
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugZPos=Column Builder Limit - Z Pos
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugXRow=Column Builder Limit - X Row
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugZRow=Column Builder Limit - Z Row
distanthorizons.config.client.advanced.debugging.columnBuilderDebugging.columnBuilderDebugColumnIndex=Column Builder Limit - Col Index
distanthorizons.config.client.advanced.debugging.f3Screen=F3 Screen
distanthorizons.config.client.advanced.debugging.f3Screen.showPlayerPos=Show Player Pos
distanthorizons.config.client.advanced.debugging.f3Screen.playerPosSectionDetailLevel=Player Section Pos Detail Level
distanthorizons.config.client.advanced.debugging.f3Screen.showThreadPools=Show Thread Pools
distanthorizons.config.client.advanced.debugging.f3Screen.showCombinedObjectPools=Show Combined Object Pools
distanthorizons.config.client.advanced.debugging.f3Screen.showSeparatedObjectPools=Show Separated Object Pools
distanthorizons.config.client.advanced.debugging.f3Screen.showQueuedChunkUpdateCount=Show Queued Chunk Update Count
distanthorizons.config.client.advanced.debugging.f3Screen.showLevelStatus=Show Level Status
distanthorizons.config.client.advanced.debugging.f3Screen.onlyShowRenderingLevels=Only Show Rendering Levels
distanthorizons.config.client.advanced.debugging.exampleConfigScreen=Debug Config Screen
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.debugConfigScreenNote=This screen is to debug features of the config screen
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.boolTest=Boolean test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.byteTest=Byte test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.intTest=Integer test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.doubleTest=Double test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.shortTest=Short test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.longTest=Long test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.floatTest=Float test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.stringTest=String test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.uiButtonTest=UI Button test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.listTest=List (ArrayList) test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.mapTest=Map (HashMap) test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.categoryTest=Category test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.linkableTest=Linkable test
distanthorizons.config.client.advanced.debugging.exampleConfigScreen.linkableTest.@tooltip=The value of this should be the same as in Category Test
distanthorizons.config.common=Common
distanthorizons.config.common.worldGenerator=World Generator
distanthorizons.config.common.worldGenerator.enableDistantGeneration=Enable Distant Generation
distanthorizons.config.common.worldGenerator.enableDistantGeneration.@tooltip=§6True:§r in single player LODs will be created outside the vanilla render distance.\nDepending on the Generator Mode pre-existing chunks will be important and/o\nmissing chunks will be generated.\nNote: this can use a large amount of CPU.\n\n§6False:§r LODs will only generate within the vanilla render distance.
distanthorizons.config.common.worldGenerator.distantGeneratorMode=Distance Generator Mode
distanthorizons.config.common.worldGenerator.distantGeneratorMode.@tooltip=How complicated the generation should be when generating LODs outside the vanilla render distance.
distanthorizons.config.common.worldGenerator.showGenerationProgress=Show Generation Progress
distanthorizons.config.common.worldGenerator.showGenerationProgress.@tooltip=Determines how should distant generator progress be displayed.
distanthorizons.config.common.worldGenerator.generationProgressDisplayIntervalInSeconds=Progress Display Interval In Seconds
distanthorizons.config.common.worldGenerator.generationProgressDisplayIntervalInSeconds.@tooltip=Determines how long between progress update displays.
distanthorizons.config.common.worldGenerator.generationProgressDisableMessageDisplayTimeInSeconds=Seconds To Show Progress Hiding Instructions
distanthorizons.config.common.worldGenerator.generationProgressDisableMessageDisplayTimeInSeconds.@tooltip=For how many seconds should instructions for disabling the distant generator progress be displayed? \nSetting this to 0 hides the instructional message so the world gen progress is shown immediately when it starts.
distanthorizons.config.common.worldGenerator.generationProgressIncludeChunksPerSecond=Show Generation Speed in Chunks/Second
distanthorizons.config.common.worldGenerator.generationProgressIncludeChunksPerSecond.@tooltip=When logging generation progress also include the rate at which chunks \nare being generated. \nThis can be useful for troubleshooting performance.
distanthorizons.config.common.lodBuilding=Lod Building
distanthorizons.config.common.lodBuilding.disableUnchangedChunkCheck=Disable Unchanged Chunk Check
distanthorizons.config.common.lodBuilding.disableUnchangedChunkCheck.@tooltip=Disabling this check may fix issues where LODs aren't updated after\nblocks have been changed.\n
distanthorizons.config.common.lodBuilding.pullLightingForPregeneratedChunks=Pull Lighting For Pre-generated Chunks
distanthorizons.config.common.lodBuilding.pullLightingForPregeneratedChunks.@tooltip=If true LOD generation for pre-existing chunks will attempt to pull the lighting data \nsaved in Minecraft's Region files. \nIf false DH will pull in chunks without lighting and re-light them. \n\nSetting this to true will result in faster LOD generation \nfor already generated worlds, but is broken by most lighting mods. \n\nSet this to false if LODs are black.
distanthorizons.config.common.lodBuilding.assumePreExistingChunksAreFinished=Assume Pre-Existing Chunks Are Finished
distanthorizons.config.common.lodBuilding.assumePreExistingChunksAreFinished.@tooltip=Setting this to true may solve some issues when using DH with a pre-generated world.
distanthorizons.config.common.lodBuilding.dataCompression=Data Compression
distanthorizons.config.common.lodBuilding.dataCompression.@tooltip=What algorithm should be used to compress new LOD data? \nThis setting will only affect new or updated LOD data, \nany data already generated when this setting is changed will be \nunaffected until it needs to be re-written to the database. \n\nFastest: LZ4 \nHighest Compression: LZMA2
distanthorizons.config.common.lodBuilding.worldCompression=Lossy World Compression
distanthorizons.config.common.lodBuilding.worldCompression.@tooltip=How should block data be compressed when creating LOD data? \nThis setting will only affect new or updated LOD data, \nany data already generated when this setting is changed will be \nunaffected until it is modified or re-loaded. \n\nMost Accurate: Merge Same Blocks \nHighest Compression: Visually Equal
distanthorizons.config.common.lodBuilding.recalculateChunkHeightmaps=Recalculate Chunk Heightmaps
distanthorizons.config.common.lodBuilding.recalculateChunkHeightmaps.@tooltip=True: Recalculate chunk height maps before chunks can be used by DH. This can fix problems with worlds created by external tools. \nFalse: Assume any height maps handled by Minecraft are correct. \n\nFastest: False\nMost Compatible: True
distanthorizons.config.common.lodBuilding.showMigrationChatWarning=Log Migration In Chat
distanthorizons.config.common.lodBuilding.experimental=Experimental
distanthorizons.config.common.lodBuilding.experimental.upsampleLowerDetailLodsToFillHoles=Upsample Lower Detail LODs To Fill Holes
distanthorizons.config.common.lodBuilding.experimental.upsampleLowerDetailLodsToFillHoles.@tooltip=When active DH will attempt to fill missing LOD data \nwith any data that is present in the tree, preventing holes when moving \nwhen a N-sized generator (or server) is active. \n\n§6EXPERIMENTAL§r Will increase harddrive use and may cause rendering issues. \nSee the config file for more details.
distanthorizons.config.common.multiThreading=Multi-Threading
distanthorizons.config.common.multiThreading.numberOfThreads=NO. of threads
distanthorizons.config.common.multiThreading.numberOfThreads.@tooltip=How many threads DH will use.
distanthorizons.config.common.multiThreading.threadRunTimeRatio=Runtime % for threads
distanthorizons.config.common.multiThreading.threadPriority=Thread Priority
distanthorizons.config.common.multiThreading.threadPriority.@tooltip=What Java thread priority should DH's primary thread pools run with?\n\nYou probably don't need to change this unless you are also \nrunning C2ME and are seeing thread starvation in either C2ME or DH.
distanthorizons.config.common.logging=Logging
distanthorizons.config.common.logging.@tooltip=Controls how logging should be handled.
distanthorizons.config.common.logging.globalFileMaxLevel=Global File Max
distanthorizons.config.common.logging.globalChatMaxLevel=Global Chat Max
distanthorizons.config.common.logging.logWorldGenEventToFile=World Gen Events - File
distanthorizons.config.common.logging.logWorldGenPerformanceToFile=World Gen Performance - File
distanthorizons.config.common.logging.logWorldGenChunkLoadEventToFile=World Gen Load Events - File
distanthorizons.config.common.logging.logRendererEventToFile=Renderer Events - File
distanthorizons.config.common.logging.logRendererGLEventToFile=OpenGL Events - File
distanthorizons.config.common.logging.logRendererGLEventToChat=OpenGL Events - Chat
distanthorizons.config.common.logging.logNetworkEventToFile=Network Events - File
distanthorizons.config.common.logging.logConnectionConfigChangesToFile=Network Connection Config Changes - File
distanthorizons.config.common.logging.warning=Warnings
distanthorizons.config.common.logging.warning.showLowMemoryWarningOnStartup=Show Low Memory Warning On Startup
distanthorizons.config.common.logging.warning.showPoolInsufficientMemoryWarning=Show Pool Insufficient Memory Warning
distanthorizons.config.common.logging.warning.showPoolInsufficientMemoryWarning.@tooltip=If DH detects that pooled objects are being garbage collected this will send a chat warning.
distanthorizons.config.common.logging.warning.showHighVanillaRenderDistanceWarning=Show High Vanilla Render Distance Warning
distanthorizons.config.common.logging.warning.showReplayWarningOnStartup=Show Replay Warning
distanthorizons.config.common.logging.warning.showUpdateQueueOverloadedChatWarning=Show Update Queue Overloaded Warning
distanthorizons.config.common.logging.warning.showSlowWorldGenSettingWarnings=Show Slow World Gen Warnings
distanthorizons.config.common.logging.warning.showModCompatibilityWarningsOnStartup=Show Mod Compatibility Warnings
distanthorizons.config.common.logging.warning.showGarbageCollectorWarning=Show Garbage Collector Warning
distanthorizons.config.common.logging.warning.logGarbageCollectorWarning=Log Garbage Collector Warning
distanthorizons.config.server=Server
distanthorizons.config.server.sendLevelKeys=Send Level Keys
distanthorizons.config.server.sendLevelKeys.@tooltip=Makes the server send level keys for each world.\nDisable this if you use alternative ways to send level keys.
distanthorizons.config.server.levelKeyPrefix=Level Key Prefix
distanthorizons.config.server.levelKeyPrefix.@tooltip=Prefix of the level keys sent to the clients.\nIf the mod is running behind a proxy, each backend should use a unique value.\nIf this value is empty, level key will be based on the server's seed hash.
distanthorizons.config.server.enableServerGeneration=Enable Server Generation
distanthorizons.config.server.enableServerGeneration.@tooltip=When enabled, Distant Horizons will attempt to download missing LODs from the server.\n\nNote: the server must have Distant Generation enabled for it to work.
distanthorizons.config.server.generationRequestRateLimit=Rate Limit for Generation Requests
distanthorizons.config.server.generationRequestRateLimit.@tooltip=How many LOD generation requests per second should a client send?\nAlso limits the number of client requests allowed to stay in the server's queue.
distanthorizons.config.server.maxGenerationRequestDistance=Max Generation Request Distance
distanthorizons.config.server.maxGenerationRequestDistance.@tooltip=Defines the distance allowed to generate around the player.
distanthorizons.config.server.enableRealTimeUpdates=Enable Real-time Updates
distanthorizons.config.server.enableRealTimeUpdates.@tooltip=If true, clients will receive real-time LOD updates for chunks outside the client's render distance.
distanthorizons.config.server.realTimeUpdateDistanceRadiusInChunks=Real-time Update Radius in Chunks
distanthorizons.config.server.realTimeUpdateDistanceRadiusInChunks.@tooltip=Defines the distance the player will receive updates around.
distanthorizons.config.server.synchronizeOnLoad=Synchronize LODs on Load
distanthorizons.config.server.synchronizeOnLoad.@tooltip=If true, clients will receive updated LODs when joining or loading new LODs.
distanthorizons.config.server.syncOnLoadRateLimit=Rate Limit for Sync on Load
distanthorizons.config.server.syncOnLoadRateLimit.@tooltip=How many LOD sync requests per second should a client send?\nAlso limits the number of client's requests allowed to stay in the server's queue.
distanthorizons.config.server.maxSyncOnLoadRequestDistance=Max Sync on Load Request Distance
distanthorizons.config.server.maxSyncOnLoadRequestDistance.@tooltip=Defines the distance allowed to be synchronized around the player.\nShould be the same or larger than maxGenerationRequestDistance in most cases.
distanthorizons.config.server.playerBandwidthLimit=Per-player Bandwidth Limit, KB/s
distanthorizons.config.server.playerBandwidthLimit.@tooltip=Maximum per-player speed for uploading LODs to the clients, in KB/s.\nValue of 0 disables the limit.
distanthorizons.config.server.globalBandwidthLimit=Global Bandwidth Limit, KB/s
distanthorizons.config.server.globalBandwidthLimit.@tooltip=Maximum global speed for uploading LODs to the clients, in KB/s.\nValue of 0 disables the limit.
distanthorizons.config.server.enableAdaptiveTransferSpeed=Enable Adaptive Transfer Speed
distanthorizons.config.server.enableAdaptiveTransferSpeed.@tooltip=Enables adaptive transfer speed based on client performance.\nIf true, DH will automatically adjust transfer rate to minimize connection lag.\nIf false, transfer speed will remain fixed.
distanthorizons.config.server.experimental=Experimental
distanthorizons.config.server.experimental.enableNSizedGeneration=Enable N-sized generation
distanthorizons.config.server.experimental.enableNSizedGeneration.@tooltip=When enabled on the client, this allows loading lower detail levels as needed to speed up terrain generation.\nThis must also be enabled on the server; otherwise, it will have no effect.\nFor better performance when switching LOD detail levels, enabling [upsampleLowerDetailLodsToFillHoles] is recommended.
distanthorizons.config.enum.EDhApiQualityPreset.CUSTOM=Custom
distanthorizons.config.enum.EDhApiQualityPreset.MINIMUM=1. Minimum
distanthorizons.config.enum.EDhApiQualityPreset.LOW=2. Low
distanthorizons.config.enum.EDhApiQualityPreset.MEDIUM=3. Medium
distanthorizons.config.enum.EDhApiQualityPreset.HIGH=4. High
distanthorizons.config.enum.EDhApiQualityPreset.EXTREME=5. Extreme
distanthorizons.config.enum.EDhApiThreadPreset.CUSTOM=Custom
distanthorizons.config.enum.EDhApiThreadPreset.MINIMAL_IMPACT=1. Minimal Impact
distanthorizons.config.enum.EDhApiThreadPreset.LOW_IMPACT=2. Low Impact
distanthorizons.config.enum.EDhApiThreadPreset.BALANCED=3. Balanced
distanthorizons.config.enum.EDhApiThreadPreset.AGGRESSIVE=4. Aggressive
distanthorizons.config.enum.EDhApiThreadPreset.I_PAID_FOR_THE_WHOLE_CPU=5. I Paid For The Whole CPU
distanthorizons.config.enum.EDhApiMaxHorizontalResolution.BLOCK=1. Block
distanthorizons.config.enum.EDhApiMaxHorizontalResolution.TWO_BLOCKS=2. 2 blocks
distanthorizons.config.enum.EDhApiMaxHorizontalResolution.FOUR_BLOCKS=3. 4 blocks
distanthorizons.config.enum.EDhApiMaxHorizontalResolution.HALF_CHUNK=4. Half a chunk
distanthorizons.config.enum.EDhApiMaxHorizontalResolution.CHUNK=5. Chunk
distanthorizons.config.enum.EDhApiMcRenderingFadeMode.NONE=None
distanthorizons.config.enum.EDhApiMcRenderingFadeMode.SINGLE_PASS=Single Pass
distanthorizons.config.enum.EDhApiMcRenderingFadeMode.DOUBLE_PASS=Double Pass
distanthorizons.config.enum.EDhApiVerticalQuality.HEIGHT_MAP=1. Height Map
distanthorizons.config.enum.EDhApiVerticalQuality.LOW=2. Low
distanthorizons.config.enum.EDhApiVerticalQuality.MEDIUM=3. Medium
distanthorizons.config.enum.EDhApiVerticalQuality.HIGH=4. High
distanthorizons.config.enum.EDhApiVerticalQuality.VERY_HIGH=5. Very High
distanthorizons.config.enum.EDhApiVerticalQuality.EXTREME=6. Extreme
distanthorizons.config.enum.EDhApiVerticalQuality.PIXEL_ART=7. Pixel Art
distanthorizons.config.enum.EDhApiHorizontalQuality.LOWEST=Lowest
distanthorizons.config.enum.EDhApiHorizontalQuality.LOW=Low
distanthorizons.config.enum.EDhApiHorizontalQuality.MEDIUM=Medium
distanthorizons.config.enum.EDhApiHorizontalQuality.HIGH=High
distanthorizons.config.enum.EDhApiHorizontalQuality.EXTREME=Extreme
distanthorizons.config.enum.EDhApiTransparency.DISABLED=Disabled
distanthorizons.config.enum.EDhApiTransparency.FAKE=Fake
distanthorizons.config.enum.EDhApiTransparency.COMPLETE=Complete
distanthorizons.config.enum.EDhApiFogDrawMode.USE_OPTIFINE_SETTING=Use modded settings
distanthorizons.config.enum.EDhApiFogDrawMode.FOG_ENABLED=Enabled
distanthorizons.config.enum.EDhApiFogDrawMode.FOG_DISABLED=Disabled
distanthorizons.config.enum.EDhApiFogColorMode.USE_WORLD_FOG_COLOR=Use world fog
distanthorizons.config.enum.EDhApiFogColorMode.USE_SKY_COLOR=Use sky color
distanthorizons.config.enum.EDhApiFogFalloff.LINEAR=Linear
distanthorizons.config.enum.EDhApiFogFalloff.EXPONENTIAL=Exponential
distanthorizons.config.enum.EDhApiFogFalloff.EXPONENTIAL_SQUARED=Exponential squared
distanthorizons.config.enum.EDhApiHeightFogMixMode.SPHERICAL=Spherical
distanthorizons.config.enum.EDhApiHeightFogMixMode.CYLINDRICAL=Cylindrical
distanthorizons.config.enum.EDhApiHeightFogMixMode.ADDITION=Addition
distanthorizons.config.enum.EDhApiHeightFogMixMode.MAX=Max
distanthorizons.config.enum.EDhApiHeightFogMixMode.MULTIPLY=Multiply
distanthorizons.config.enum.EDhApiHeightFogMixMode.INVERSE_MULTIPLY=Inverse Multiply
distanthorizons.config.enum.EDhApiHeightFogMixMode.LIMITED_ADDITION=Limited Addition
distanthorizons.config.enum.EDhApiHeightFogMixMode.MULTIPLY_ADDITION=Multiply Addition
distanthorizons.config.enum.EDhApiHeightFogMixMode.INVERSE_MULTIPLY_ADDITION=Inverse Multiply Addition
distanthorizons.config.enum.EDhApiHeightFogMixMode.AVERAGE=Average
distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_CAMERA=Above Camera
distanthorizons.config.enum.EDhApiHeightFogDirection.BELOW_CAMERA=Below Camera
distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_AND_BELOW_CAMERA=Above And Below Camera
distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_SET_HEIGHT=Above Set Height
distanthorizons.config.enum.EDhApiHeightFogDirection.BELOW_SET_HEIGHT=Below Set Height
distanthorizons.config.enum.EDhApiHeightFogDirection.ABOVE_AND_BELOW_SET_HEIGHT=Above And Below Set Height
distanthorizons.config.enum.EDhApiVanillaOverdraw.NEVER=Never
distanthorizons.config.enum.EDhApiVanillaOverdraw.DYNAMIC=Dynamic
distanthorizons.config.enum.EDhApiVanillaOverdraw.ALWAYS=Always
distanthorizons.config.enum.EDhApiDistantGeneratorMode.NONE=1. Existing Only
distanthorizons.config.enum.EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY=2. Pre-Existing Chunks only
distanthorizons.config.enum.EDhApiDistantGeneratorMode.BIOME_ONLY=3. Biome only
distanthorizons.config.enum.EDhApiDistantGeneratorMode.BIOME_ONLY_SIMULATE_HEIGHT=4. Biome only simulate height
distanthorizons.config.enum.EDhApiDistantGeneratorMode.SURFACE=5. Surface
distanthorizons.config.enum.EDhApiDistantGeneratorMode.FEATURES=6. Features
distanthorizons.config.enum.EDhApiDistantGeneratorMode.INTERNAL_SERVER=7. Full - Save Chunks
distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.OVERLAY=Overlay
distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.CHAT=Chat
distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.LOG=Log
distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.DISABLED=Disabled
distanthorizons.config.enum.EDhApiDataCompressionMode.UNCOMPRESSED=Uncompressed
distanthorizons.config.enum.EDhApiDataCompressionMode.LZ4=Fastest/Big - LZ4
distanthorizons.config.enum.EDhApiDataCompressionMode.Z_STD_BLOCK=Fastest/Small - Z_STD - Block
distanthorizons.config.enum.EDhApiDataCompressionMode.Z_STD_STREAM=Fast/Small - Z_STD - Stream
distanthorizons.config.enum.EDhApiDataCompressionMode.LZMA2=Slow/Smallest - LZMA2
distanthorizons.config.enum.EDhApiWorldCompressionMode.MERGE_SAME_BLOCKS=1. Merge Same Blocks
distanthorizons.config.enum.EDhApiWorldCompressionMode.VISUALLY_EQUAL=2. Visually Equal
distanthorizons.config.enum.EDhApiBlocksToAvoid.NONE=None
distanthorizons.config.enum.EDhApiBlocksToAvoid.NON_COLLIDING=Non-Colliding
distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_ONLY=Name Only
distanthorizons.config.enum.EDhApiServerFolderNameMode.IP_ONLY=IP Only
distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP=Name and IP
distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP_PORT=Name, IP, Port
distanthorizons.config.enum.EDhApiServerFolderNameMode.NAME_IP_PORT_MC_VERSION=Name, IP, Port, MC version
distanthorizons.config.enum.EDhApiRendererMode.DEFAULT=Default
distanthorizons.config.enum.EDhApiRendererMode.DEBUG=Debug
distanthorizons.config.enum.EDhApiRendererMode.DISABLED=Disabled
distanthorizons.config.enum.EDhApiDebugRendering.OFF=Off
distanthorizons.config.enum.EDhApiDebugRendering.SHOW_DETAIL=Show detail
distanthorizons.config.enum.EDhApiDebugRendering.SHOW_GENMODE=Show generation mode
distanthorizons.config.enum.EDhApiDebugRendering.SHOW_BLOCK_MATERIAL=Show Material
distanthorizons.config.enum.EDhApiDebugRendering.SHOW_OVERLAPPING_QUADS=Show overlapping quads
distanthorizons.config.enum.EDhApiDebugRendering.SHOW_RENDER_SOURCE_FLAG=Show render source flag
distanthorizons.config.enum.EDhApiGLErrorHandlingMode.IGNORE=Ignore
distanthorizons.config.enum.EDhApiGLErrorHandlingMode.LOG=Log
distanthorizons.config.enum.EDhApiGLErrorHandlingMode.LOG_THROW=Log-Throw
distanthorizons.config.enum.EDhApiGlProfileMode.CORE=Core
distanthorizons.config.enum.EDhApiGlProfileMode.COMPAT=Compat
distanthorizons.config.enum.EDhApiGlProfileMode.ANY=Any
distanthorizons.config.enum.EDhApiLoggerLevel.ALL=1. All
distanthorizons.config.enum.EDhApiLoggerLevel.DEBUG=2. Debug
distanthorizons.config.enum.EDhApiLoggerLevel.INFO=3. Info
distanthorizons.config.enum.EDhApiLoggerLevel.WARN=4. Warn
distanthorizons.config.enum.EDhApiLoggerLevel.ERROR=5. Error
distanthorizons.config.enum.EDhApiLoggerLevel.DISABLED=6. Disabled
distanthorizons.config.enum.EDhApiGpuUploadMethod.AUTO=Auto
distanthorizons.config.enum.EDhApiGpuUploadMethod.NONE=None
distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_STORAGE=Buffer storage
distanthorizons.config.enum.EDhApiGpuUploadMethod.SUB_DATA=Sub data
distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_MAPPING=Buffer mapping
distanthorizons.config.enum.EDhApiGpuUploadMethod.DATA=Data
distanthorizons.config.enum.EDhApiLodShading.AUTO=Auto
distanthorizons.config.enum.EDhApiLodShading.ENABLED=Enabled
distanthorizons.config.enum.EDhApiLodShading.DISABLED=Disabled
distanthorizons.config.enum.EDhApiUpdateBranch.STABLE=Stable
distanthorizons.config.enum.EDhApiUpdateBranch.NIGHTLY=Nightly
distanthorizons.config.enum.EDhApiUpdateBranch.AUTO=Auto
distanthorizons.config.enum.EDhApiGrassSideRendering.AS_GRASS=As Grass
distanthorizons.config.enum.EDhApiGrassSideRendering.FADE_TO_DIRT=Fade To Dirt
distanthorizons.config.enum.EDhApiGrassSideRendering.AS_DIRT=As Dirt
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="700pt"
height="700pt"
version="1.1"
viewBox="0 0 700 700"
id="svg4"
sodipodi:docname="themeDark.svg"
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs8" />
<sodipodi:namedview
id="namedview6"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="pt"
showgrid="false"
inkscape:zoom="0.79607143"
inkscape:cx="466.66667"
inkscape:cy="466.03858"
inkscape:window-width="2560"
inkscape:window-height="1351"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="m573.12 450.62c-1.5625-3.2305-4.0781-5.9023-7.207-7.6562-3.1289-1.7539-6.7227-2.5-10.293-2.1445-52.113 7.4141-105.18-3.3867-150.25-30.578-45.07-27.191-79.371-69.105-97.113-118.66-17.738-49.555-17.832-103.71-0.25781-153.33 12.207-34.535 32.625-65.586 59.5-90.477 3.8047-3.4023 5.9336-8.3008 5.8242-13.406-0.10938-5.1055-2.4414-9.9102-6.3867-13.152-3.9453-3.2422-9.1094-4.5977-14.137-3.7148-55.062 7.5039-106.35 32.211-146.54 70.594s-67.223 88.48-77.246 143.14c-10.023 54.656-2.5273 111.09 21.422 161.23 23.949 50.145 63.129 91.441 111.94 118 48.816 26.559 104.77 37.016 159.89 29.883 55.109-7.1328 106.56-31.492 147-69.602 2.6758-2.5234 4.4883-5.8281 5.1797-9.4414 0.69141-3.6133 0.22656-7.3516-1.3281-10.684z"
id="path2"
style="fill:#003380" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="700pt"
height="700pt"
version="1.1"
viewBox="0 0 700 700"
id="svg22"
sodipodi:docname="themeLight.svg"
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs26" />
<sodipodi:namedview
id="namedview24"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="pt"
showgrid="false"
inkscape:zoom="0.79607143"
inkscape:cx="466.66667"
inkscape:cy="466.03858"
inkscape:window-width="2560"
inkscape:window-height="1351"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg22" />
<g
id="g20"
style="fill:#55d400">
<path
d="m472.5 280c0 67.656-54.844 122.5-122.5 122.5s-122.5-54.844-122.5-122.5 54.844-122.5 122.5-122.5 122.5 54.844 122.5 122.5"
id="path2"
style="fill:#55d400" />
<path
d="m350 140c4.6406 0 9.0938-1.8438 12.375-5.125s5.125-7.7344 5.125-12.375v-87.5c0-6.2539-3.3359-12.031-8.75-15.156s-12.086-3.125-17.5 0-8.75 8.9023-8.75 15.156v87.5c0 4.6406 1.8438 9.0938 5.125 12.375s7.7344 5.125 12.375 5.125z"
id="path4"
style="fill:#55d400" />
<path
d="m226.27 180.95c3.1719 3.7031 7.7461 5.918 12.617 6.1055 4.875 0.1875 9.6016-1.6641 13.051-5.1133 3.4492-3.4492 5.3008-8.1758 5.1133-13.051-0.1875-4.8711-2.4023-9.4453-6.1055-12.617l-61.773-61.949c-4.4414-4.4375-10.91-6.1719-16.973-4.5469-6.0664 1.625-10.801 6.3594-12.426 12.426-1.625 6.0625 0.10938 12.531 4.5469 16.973z"
id="path6"
style="fill:#55d400" />
<path
d="m210 280c0-4.6406-1.8438-9.0938-5.125-12.375s-7.7344-5.125-12.375-5.125h-87.5c-6.2539 0-12.031 3.3359-15.156 8.75s-3.125 12.086 0 17.5 8.9023 8.75 15.156 8.75h87.5c4.6406 0 9.0938-1.8438 12.375-5.125s5.125-7.7344 5.125-12.375z"
id="path8"
style="fill:#55d400" />
<path
d="m226.27 379.05-61.949 61.773c-3.7031 3.1719-5.9141 7.7461-6.1016 12.617-0.19141 4.8711 1.6641 9.6016 5.1094 13.051 3.4492 3.4453 8.1797 5.3008 13.051 5.1133 4.8711-0.19141 9.4453-2.4023 12.617-6.1055l61.949-61.949c3.8594-4.5078 5.1719-10.66 3.4922-16.348-1.6836-5.6875-6.1328-10.137-11.82-11.816-5.6875-1.6836-11.84-0.37109-16.348 3.4883z"
id="path10"
style="fill:#55d400" />
<path
d="m350 420c-4.6406 0-9.0938 1.8438-12.375 5.125s-5.125 7.7344-5.125 12.375v87.5c0 6.2539 3.3359 12.031 8.75 15.156s12.086 3.125 17.5 0 8.75-8.9023 8.75-15.156v-87.5c0-4.6406-1.8438-9.0938-5.125-12.375s-7.7344-5.125-12.375-5.125z"
id="path12"
style="fill:#55d400" />
<path
d="m473.73 379.05c-4.5078-3.8594-10.66-5.1719-16.348-3.4922-5.6875 1.6836-10.137 6.1328-11.82 11.82-1.6797 5.6875-0.36719 11.84 3.4922 16.348l61.949 61.949c4.5039 3.8555 10.656 5.1719 16.348 3.4883 5.6875-1.6797 10.137-6.1289 11.816-11.816 1.6836-5.6914 0.36719-11.844-3.4883-16.348z"
id="path14"
style="fill:#55d400" />
<path
d="m595 262.5h-87.5c-6.2539 0-12.031 3.3359-15.156 8.75s-3.125 12.086 0 17.5 8.9023 8.75 15.156 8.75h87.5c6.2539 0 12.031-3.3359 15.156-8.75s3.125-12.086 0-17.5-8.9023-8.75-15.156-8.75z"
id="path16"
style="fill:#55d400" />
<path
d="m461.3 186.2c4.6523 0.027343 9.1211-1.7969 12.426-5.0742l61.949-61.949c3.8555-4.5078 5.1719-10.66 3.4883-16.348-1.6797-5.6875-6.1289-10.137-11.816-11.816-5.6914-1.6836-11.844-0.37109-16.348 3.4883l-61.949 61.773c-3.3086 3.2852-5.1719 7.75-5.1758 12.414-0.003906 4.6602 1.8516 9.1289 5.1562 12.418 3.3047 3.2891 7.7812 5.1211 12.445 5.0938z"
id="path18"
style="fill:#55d400" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

@@ -0,0 +1,10 @@
<?xml version="1.0" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<!-- No icon texture for DH -->
<rect width="50" height="50" x="0" y="0" style="fill:#0000FF" />
<rect width="50" height="50" x="50" y="50" style="fill:#0000FF" />
<rect width="50" height="50" x="50" y="0" style="fill:#000000" />
<rect width="50" height="50" x="0" y="50" style="fill:#000000" />
</svg>

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,19 @@
{
"required": true,
"package": "com.seibel.distanthorizons.cleanroom.mixins",
"compatibilityLevel": "JAVA_8",
"target": "@env(DEFAULT)",
"mixins": [
"common.MixinChunkProviderServer"
],
"minVersion": "0.8.7",
"server": [
"server.MixinEntityPlayerMP"
],
"client": [
"client.MixinEntityRenderer",
"client.MixinNetHandlerPlayClient",
"client.MixinOptionsScreen",
"client.MixinRenderGlobal"
]
}
@@ -0,0 +1,11 @@
{
"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": [
]
}
@@ -0,0 +1,33 @@
#version 150 core
in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D gDhColorTexture;
uniform sampler2D gDhDepthTexture;
/**
* LOD application shader
*
* This merges the rendered LODs into Minecraft's texture/FBO
*/
void main()
{
fragColor = vec4(0.0);
// a fragment depth of "1" means the fragment wasn't drawn to,
// only update fragments that were drawn to
float fragmentDepth = texture(gDhDepthTexture, TexCoord).r;
if (fragmentDepth != 1)
{
fragColor = texture(gDhColorTexture, TexCoord);
}
else
{
// use the original MC texture if no LODs were drawn to this fragment
discard;
}
}
@@ -0,0 +1,10 @@
#version 150 core
uniform vec4 uColor;
out vec4 fragColor;
void main()
{
fragColor = uColor;
}
@@ -0,0 +1,10 @@
#version 150 core
uniform mat4 uTransform;
in vec3 vPosition;
void main()
{
gl_Position = uTransform * vec4(vPosition, 1.0);
}
@@ -0,0 +1,14 @@
#version 150 core
in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D uFadeColorTextureUniform;
void main()
{
fragColor = texture(uFadeColorTextureUniform, TexCoord);
}
@@ -0,0 +1,65 @@
#version 150 core
in vec2 TexCoord;
out vec4 fragColor;
// inverted model view matrix and projection matrix
uniform mat4 uDhInvMvmProj;
uniform sampler2D uDhDepthTexture;
uniform sampler2D uMcColorTexture;
uniform sampler2D uDhColorTexture;
uniform float uStartFadeBlockDistance;
uniform float uEndFadeBlockDistance;
vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj)
{
// normalized device coordinates
vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0);
ndc.xyz = ndc.xyz * 2.0 - 1.0;
vec4 eyeCoord = invMvmProj * ndc;
return eyeCoord.xyz / eyeCoord.w;
}
/**
* Used to fade out vanilla chunks so the transition
* between DH and vanilla is smoother.
*/
void main()
{
// includes both the vanilla chunks as well as DH
vec4 combinedMcDhColor = texture(uMcColorTexture, TexCoord);
// just the DH render pass
vec4 dhColor = texture(uDhColorTexture, TexCoord);
// the DH texture will have white if nothing was written to that pixel.
if (dhColor == vec4(1))
{
// if not done vanilla clouds will render incorrectly at night
dhColor = combinedMcDhColor;
}
float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r;
vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj);
float dhFragmentDistance = length(dhVertexWorldPos.xzy);
float startFade = uEndFadeBlockDistance;
float endFade = uStartFadeBlockDistance;
// Smoothly transition between combinedMcDhColor and uDhColorTexture
// as the depth increases from the camera
float fadeStep = smoothstep(startFade, endFade, dhFragmentDistance);
fragColor = mix(combinedMcDhColor, dhColor, fadeStep);
fragColor.a = 1.0;
}
@@ -0,0 +1,91 @@
#version 150 core
in vec2 TexCoord;
out vec4 fragColor;
// inverted model view matrix and projection matrix
uniform mat4 uDhInvMvmProj;
uniform mat4 uMcInvMvmProj;
uniform sampler2D uMcDepthTexture;
uniform sampler2D uDhDepthTexture;
uniform sampler2D uCombinedMcDhColorTexture;
uniform sampler2D uDhColorTexture;
uniform float uStartFadeBlockDistance;
uniform float uEndFadeBlockDistance;
uniform float uMaxLevelHeight;
uniform bool uOnlyRenderLods;
vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj)
{
// normalized device coordinates
vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0);
ndc.xyz = ndc.xyz * 2.0 - 1.0;
vec4 eyeCoord = invMvmProj * ndc;
return eyeCoord.xyz / eyeCoord.w;
}
/**
* Used to fade out vanilla chunks so the transition
* between DH and vanilla is smoother.
*/
void main()
{
// includes both the vanilla chunks as well as DH
vec4 combinedMcDhColor = texture(uCombinedMcDhColorTexture, TexCoord);
// just the DH render pass
vec4 dhColor = texture(uDhColorTexture, TexCoord);
// completely remove the MC render pass to only show LODs
// useful for debugging/troubleshooting, but doesn't improve performance since MC is still rendering
if (uOnlyRenderLods)
{
fragColor = dhColor;
return;
}
// ignore anything that DH hasn't drawn to
// We don't use DH's depth here because it would prevent the fade from running before DH has loaded
if (dhColor == vec4(1))
{
// if not done vanilla clouds will render incorrectly at night
dhColor = combinedMcDhColor;
}
float mcFragmentDepth = texture(uMcDepthTexture, TexCoord).r;
float dhFragmentDepth = texture(uDhDepthTexture, TexCoord).r;
vec3 dhVertexWorldPos = calcViewPosition(dhFragmentDepth, uDhInvMvmProj);
// this is a work around to prevent MC clouds rendering behind DH clouds
if (dhVertexWorldPos.y > uMaxLevelHeight)
{
fragColor = vec4(combinedMcDhColor.rgb, 0.0);
}
// a fragment depth of "1" means the fragment wasn't drawn to,
// we only want to fade vanilla rendered objects, not to the sky or LODs
else if (mcFragmentDepth < 1.0)
{
// fade based on distance from the camera
vec3 mcVertexWorldPos = calcViewPosition(mcFragmentDepth, uMcInvMvmProj);
float mcFragmentDistance = length(mcVertexWorldPos.xzy);
// Smoothly transition between combinedMcDhColor and uDhColorTexture
// as the depth increases from the camera
float fadeStep = smoothstep(uStartFadeBlockDistance, uEndFadeBlockDistance, mcFragmentDistance);
fragColor = mix(combinedMcDhColor, dhColor, fadeStep);
fragColor.a = 1.0;
}
else
{
fragColor = vec4(combinedMcDhColor.rgb, 0.0);
}
}
@@ -0,0 +1,123 @@
#version 150
in vec4 vertexColor;
in vec3 vertexWorldPos;
in vec4 vPos;
in vec4 gl_FragCoord;
out vec4 fragColor;
// Fade/Clip Uniforms
uniform float uClipDistance = 0.0;
// Noise Uniforms
uniform bool uNoiseEnabled;
uniform int uNoiseSteps;
uniform float uNoiseIntensity;
uniform int uNoiseDropoff;
uniform bool uDitherDhRendering;
// The random functions for diffrent dimentions
float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); }
float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); }
float rand(vec3 co) { return rand(co.xy + rand(co.z)); }
// Puts steps in a float
// EG. setting stepSize to 4 then this would be the result of this function
// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3
// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25
vec3 quantize(vec3 val, int stepSize)
{
return floor(val * stepSize) / stepSize;
}
void applyNoise(inout vec4 fragColor, const in float viewDist)
{
vec3 vertexNormal = normalize(cross(dFdy(vPos.xyz), dFdx(vPos.xyz)));
// This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable
vec3 fixedVPos = vPos.xyz + vertexNormal * 0.001;
float noiseAmplification = uNoiseIntensity;
float lum = (fragColor.r + fragColor.g + fragColor.b) / 3.0;
noiseAmplification = (1.0 - pow(lum * 2.0 - 1.0, 2.0)) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1
noiseAmplification *= fragColor.a; // The effect would lessen on transparent objects
// Random value for each position
float randomValue = rand(quantize(fixedVPos, uNoiseSteps))
* 2.0 * noiseAmplification - noiseAmplification;
// Modifies the color
// A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color
vec3 newCol = fragColor.rgb + (1.0 - fragColor.rgb) * randomValue;
newCol = clamp(newCol, 0.0, 1.0);
if (uNoiseDropoff != 0) {
float distF = min(viewDist / uNoiseDropoff, 1.0);
newCol = mix(newCol, fragColor.rgb, distF); // The further away it gets, the less noise gets applied
}
fragColor.rgb = newCol;
}
/** returns a normalized value between 0.0 and 1.0 */
float bayerMatrix4x4(vec2 st)
{
int x = int(mod(st.x, 4.0));
int y = int(mod(st.y, 4.0));
// Flattened 4x4 Bayer matrix
float bayer4x4[16] = float[16](
0.0, 8.0, 2.0, 10.0,
12.0, 4.0, 14.0, 6.0,
3.0, 11.0, 1.0, 9.0,
15.0, 7.0, 13.0, 5.0
);
// Calculate the 1D index from the 2D coordinates
int index = y * 4 + x;
// Return the Bayer value normalized between 0.0 and 1.0
return bayer4x4[index] / 16.0;
}
void main()
{
fragColor = vertexColor;
float viewDist = length(vertexWorldPos);
if (uDitherDhRendering)
{
// Dither out the fragment based on distance and noise.
// Dithering is used since it works for both opaque and transparent rendering
// noise increases as the distance increases
// the fragCoord is used since it is stable and small so the dithering is cleaner
float worldNoise = bayerMatrix4x4(gl_FragCoord.xy);
// minor fudge factor to make sure all pixels fade out
// if not included 1 in 16 pixels would never fade away
worldNoise += 0.001;
float fadeStep = smoothstep(uClipDistance, uClipDistance * 1.5, viewDist);
if (fadeStep <= worldNoise)
{
discard;
}
}
else
{
if (viewDist < uClipDistance && uClipDistance > 0.0)
{
discard;
}
}
if (uNoiseEnabled)
{
applyNoise(fragColor, viewDist);
}
}
@@ -0,0 +1,27 @@
#version 150 core
in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D uColorTexture;
uniform sampler2D uDepthTexture;
/**
* Fog application shader
*
* This merges the rendered fog onto DH's rendered LODs
*/
void main()
{
fragColor = vec4(0.0);
// a fragment depth of "1" means the fragment wasn't drawn to,
// only update fragments that were drawn to
float fragmentDepth = textureLod(uDepthTexture, TexCoord, 0).r;
if (fragmentDepth != 1)
{
fragColor = texture(uColorTexture, TexCoord);
}
}
@@ -0,0 +1,297 @@
#version 150 core
in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D uDepthMap;
// inverted model view matrix and projection matrix
uniform mat4 uInvMvmProj;
// fog uniforms
uniform vec4 uFogColor;
uniform float uFogScale;
uniform float uFogVerticalScale;
uniform int uFogDebugMode;
uniform int uFogFalloffType;
// fog config
uniform float uFarFogStart;
uniform float uFarFogLength;
uniform float uFarFogMin;
uniform float uFarFogRange;
uniform float uFarFogDensity;
// height fog config
uniform float uHeightFogStart;
uniform float uHeightFogLength;
uniform float uHeightFogMin;
uniform float uHeightFogRange;
uniform float uHeightFogDensity;
uniform bool uHeightFogEnabled;
uniform int uHeightFogFalloffType;
uniform bool uHeightBasedOnCamera;
uniform float uHeightFogBaseHeight;
uniform bool uHeightFogAppliesUp;
uniform bool uHeightFogAppliesDown;
uniform bool uUseSphericalFog;
uniform int uHeightFogMixingMode;
uniform float uCameraBlockYPos;
//====================//
// method definitions //
//====================//
vec3 calcViewPosition(float fragmentDepth);
float getFarFogThickness(float dist);
float getHeightFogThickness(float dist);
float calculateHeightFogDepth(float worldYPos);
float mixFogThickness(float far, float height);
float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange);
float exponentialFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity);
float exponentialSquaredFog(float x, float fogStart, float fogLength, float fogMin, float fogRange, float fogDensity);
//======//
// main //
//======//
/**
* Fragment shader for fog.
* This should be run last so it applies above other affects like Ambient Occlusioning
*/
void main()
{
float fragmentDepth = texture(uDepthMap, TexCoord).r;
fragColor = vec4(uFogColor.rgb, 0.0);
// a fragment depth of "1" means the fragment wasn't drawn to,
// we only want to apply Fog to LODs, not to the sky outside the LODs
if (fragmentDepth < 1.0)
{
int fogDebugMode = uFogDebugMode;
if (fogDebugMode == 0)
{
// render fog based on distance from the camera
vec3 vertexWorldPos = calcViewPosition(fragmentDepth);
float horizontalWorldDistance = length(vertexWorldPos.xz) * uFogScale;
float worldDistance = length(vertexWorldPos.xyz) * uFogScale;
float activeDistance = uUseSphericalFog ? worldDistance : horizontalWorldDistance;
// far fog
float farFogThickness = getFarFogThickness(activeDistance);
// height fog
float heightFogDepth = calculateHeightFogDepth(vertexWorldPos.y);
float heightFogThickness = getHeightFogThickness(heightFogDepth);
// combined fog
float mixedFogThickness = mixFogThickness(farFogThickness, heightFogThickness);
fragColor.a = clamp(mixedFogThickness, 0.0, 1.0);
}
else if (fogDebugMode == 1)
{
// test code
// render everything with the fog color
fragColor.a = 1.0;
}
else
{
// test code.
// this can be fired by manually changing the fullFogMode to a (normally)
// invalid value (like 7).
// By having a separate if statement defined by
// a uniform we don't have to worry about GLSL optimizing away different
// options when testing, causing a bunch of headaches if we just want to render the screen red.
float depthValue = textureLod(uDepthMap, TexCoord, 0).r;
fragColor.rgb = vec3(depthValue); // Convert depth value to grayscale color
fragColor.a = 1.0;
}
}
}
//================//
// helper methods //
//================//
vec3 calcViewPosition(float fragmentDepth)
{
vec4 ndc = vec4(TexCoord.xy, fragmentDepth, 1.0);
ndc.xyz = ndc.xyz * 2.0 - 1.0;
vec4 eyeCoord = uInvMvmProj * ndc;
return eyeCoord.xyz / eyeCoord.w;
}
//=========//
// far fog //
//=========//
float getFarFogThickness(float dist)
{
if (uFogFalloffType == 0) // LINEAR
{
return linearFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange);
}
else if (uFogFalloffType == 1) // EXPONENTIAL
{
return exponentialFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity);
}
else // EXPONENTIAL_SQUARED
{
return exponentialSquaredFog(dist, uFarFogStart, uFarFogLength, uFarFogMin, uFarFogRange, uFarFogDensity);
}
}
float getHeightFogThickness(float dist)
{
if (!uHeightFogEnabled)
{
return 0.0;
}
if (uHeightFogFalloffType == 0) // LINEAR
{
return linearFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange);
}
else if (uHeightFogFalloffType == 1) // EXPONENTIAL
{
return exponentialFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity);
}
else // EXPONENTIAL_SQUARED
{
return exponentialSquaredFog(dist, uHeightFogStart, uHeightFogLength, uHeightFogMin, uHeightFogRange, uHeightFogDensity);
}
}
float linearFog(float worldDist, float fogStart, float fogLength, float fogMin, float fogRange)
{
worldDist = (worldDist - fogStart) / fogLength;
worldDist = clamp(worldDist, 0.0, 1.0);
return fogMin + fogRange * worldDist;
}
float exponentialFog(
float x, float fogStart, float fogLength,
float fogMin, float fogRange, float fogDensity)
{
x = max((x-fogStart)/fogLength, 0.0) * fogDensity;
return fogMin + fogRange - fogRange/exp(x);
}
float exponentialSquaredFog(
float x, float fogStart, float fogLength,
float fogMin, float fogRange, float fogDensity)
{
x = max((x-fogStart)/fogLength, 0.0) * fogDensity;
return fogMin + fogRange - fogRange/exp(x*x);
}
//============//
// height fog //
//============//
/** 1 = full fog, 0 = no fog */
float calculateHeightFogDepth(float worldYPos)
{
// worldYPos -65 - 384
//worldYPos = worldYPos * -1; // negative, fog below height; positive, fog above height
//return worldYPos * uFogVerticalScale; // "* uFogVerticalScale" is done to convert world position to a percent of the world height;
if (!uHeightFogEnabled)
{
// ignore the height
return 0.0;
}
if (!uHeightBasedOnCamera)
{
worldYPos -= (uHeightFogBaseHeight - uCameraBlockYPos);
}
if (uHeightFogAppliesDown && uHeightFogAppliesUp)
{
return abs(worldYPos) * uFogVerticalScale;
}
else if (uHeightFogAppliesDown)
{
// apploy fog below given height
return -worldYPos * uFogVerticalScale;
}
else if (uHeightFogAppliesUp)
{
// apply fog above given height
return worldYPos * uFogVerticalScale;
}
else
{
// shouldn't happen,
return 0.0;
}
}
float mixFogThickness(float far, float height)
{
switch (uHeightFogMixingMode)
{
case 0: // BASIC
case 1: // IGNORE_HEIGHT
return far;
case 2: // MAX
return max(far, height);
case 3: // ADDITION
return (far + height);
case 4: // MULTIPLY
return far * height;
case 5: // INVERSE_MULTIPLY
return (1.0 - (1.0-far)*(1.0-height));
case 6: // LIMITED_ADDITION
return (far + max(far, height));
case 7: // MULTIPLY_ADDITION
return (far + far*height);
case 8: // INVERSE_MULTIPLY_ADDITION
return (far + 1.0 - (1.0-far)*(1.0-height));
case 9: // AVERAGE
return (far*0.5 + height*0.5);
}
// shouldn't happen, but default to BASIC / IGNORE_HEIGHT
// if an invalid option is selected
return far;
}
@@ -0,0 +1,10 @@
#version 150 core
in vec4 fColor;
out vec4 fragColor;
void main()
{
fragColor = fColor;
}
@@ -0,0 +1,41 @@
#version 150 core
uniform mat4 uTransform;
uniform vec4 uColor;
uniform int uSkyLight;
uniform int uBlockLight;
uniform sampler2D uLightMap;
uniform float uNorthShading;
uniform float uSouthShading;
uniform float uEastShading;
uniform float uWestShading;
uniform float uTopShading;
uniform float uBottomShading;
in vec3 vPosition;
out vec4 fColor;
void main()
{
gl_Position = uTransform * vec4(vPosition, 1.0);
float blockLight = (float(uBlockLight)+0.5) / 16.0;
float skyLight = (float(uSkyLight)+0.5) / 16.0;
vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0);
fColor = lightColor * uColor;
// apply directional shading
if (gl_VertexID >= 0 && gl_VertexID < 4) { fColor.rgb *= uNorthShading; }
else if (gl_VertexID >= 4 && gl_VertexID < 8) { fColor.rgb *= uSouthShading; }
else if (gl_VertexID >= 8 && gl_VertexID < 12) { fColor.rgb *= uWestShading; }
else if (gl_VertexID >= 12 && gl_VertexID < 16) { fColor.rgb *= uEastShading; }
else if (gl_VertexID >= 16 && gl_VertexID < 20) { fColor.rgb *= uBottomShading; }
else if (gl_VertexID >= 20 && gl_VertexID < 24) { fColor.rgb *= uTopShading; }
}
@@ -0,0 +1,10 @@
#version 150 core
in vec4 fColor;
out vec4 fragColor;
void main()
{
fragColor = fColor;
}
@@ -0,0 +1,66 @@
#version 330 core
layout (location = 1) in vec4 aColor;
layout (location = 2) in vec3 aScale;
layout (location = 3) in ivec3 aTranslateChunk;
layout (location = 4) in vec3 aTranslateSubChunk;
layout (location = 5) in int aMaterial;
uniform ivec3 uOffsetChunk;
uniform vec3 uOffsetSubChunk;
uniform ivec3 uCameraPosChunk;
uniform vec3 uCameraPosSubChunk;
uniform mat4 uProjectionMvm;
uniform int uSkyLight;
uniform int uBlockLight;
uniform sampler2D uLightMap;
uniform float uNorthShading;
uniform float uSouthShading;
uniform float uEastShading;
uniform float uWestShading;
uniform float uTopShading;
uniform float uBottomShading;
in vec3 vPosition;
out vec4 fColor;
void main()
{
// aTranslate - moves the vertex to the boxGroup's relative position
// uOffset - moves the vertex to the boxGroup's world position
// uCameraPos - moves the vertex into camera space
vec3 trans = (aTranslateChunk + uOffsetChunk - uCameraPosChunk) * 16.0f;
// separate float and int values are to fix percission loss at extreme distances from the origin (IE 10,000,000+)
// luckily large translate values minus large cameraPos generally equal values that cleanly fit in a float
trans += (aTranslateSubChunk + uOffsetSubChunk - uCameraPosSubChunk);
// combination translation and scaling matrix
mat4 transform = mat4(
aScale.x, 0.0, 0.0, 0.0,
0.0, aScale.y, 0.0, 0.0,
0.0, 0.0, aScale.z, 0.0,
trans.x, trans.y, trans.z, 1.0
);
gl_Position = uProjectionMvm * transform * vec4(vPosition, 1.0);
float blockLight = (float(uBlockLight)+0.5) / 16.0;
float skyLight = (float(uSkyLight)+0.5) / 16.0;
vec4 lightColor = vec4(texture(uLightMap, vec2(blockLight, skyLight)).xyz, 1.0);
fColor = lightColor * aColor;
// apply directional shading
if (gl_VertexID >= 0 && gl_VertexID < 4) { fColor.rgb *= uNorthShading; }
else if (gl_VertexID >= 4 && gl_VertexID < 8) { fColor.rgb *= uSouthShading; }
else if (gl_VertexID >= 8 && gl_VertexID < 12) { fColor.rgb *= uWestShading; }
else if (gl_VertexID >= 12 && gl_VertexID < 16) { fColor.rgb *= uEastShading; }
else if (gl_VertexID >= 16 && gl_VertexID < 20) { fColor.rgb *= uBottomShading; }
else if (gl_VertexID >= 20 && gl_VertexID < 24) { fColor.rgb *= uTopShading; }
}
@@ -0,0 +1,74 @@
#version 150 core
in vec4 vertexColor;
in vec4 vPos;
in vec3 vertexWorldPos;
out vec4 fragColor;
uniform float distanceScale;
uniform int uNoiseSteps;
uniform float uNoiseIntensity;
uniform float uNoiseDropoff;
// The random functions for diffrent dimentions
float rand(float co) { return fract(sin(co*(91.3458)) * 47453.5453); }
float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); }
float rand(vec3 co){ return rand(co.xy+rand(co.z)); }
// Puts steps in a float
// EG. setting stepSize to 4 then this would be the result of this function
// In: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, ..., 1.1, 1.2, 1.3
// Out: 0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, ..., 1.0, 1.0, 1.25
float quantize(float val, int stepSize) {
return floor(val*stepSize)/stepSize;
}
vec3 quantize(vec3 val, int stepSize) {
return floor(val*stepSize)/stepSize;
}
/**
* Fragment shader for adding noise to lods.
* This should be passed close to first as it affects the base color of the lod
*
* version: 2023-6-21
*/
void main() {
// This bit of code is required to fix the vertex position problem cus of floats in the verted world position varuable
vec3 vertexNormal = normalize(cross(dFdx(vPos.xyz), dFdy(vPos.xyz)));
vec3 fixedVPos = vPos.xyz - vertexNormal * 0.001;
float noiseAmplification = uNoiseIntensity;
noiseAmplification = (-1 * pow(2*((vertexColor.x + vertexColor.y + vertexColor.z) / 3) - 1, 2) + 1) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1
noiseAmplification *= vertexColor.w; // The effect would lessen on transparent objects
// Random value for each position
float randomValue = rand(quantize(fixedVPos.xyz, uNoiseSteps))
* 2.0 * noiseAmplification - noiseAmplification;
// Modifies the color
// A value of 0 on the randomValue will result in the original color, while a value of 1 will result in a fully bright color
vec3 newCol = (1.0 - vertexColor.rgb) * randomValue;
// Clamps it and turns it back into a vec4
float distA = length(vertexWorldPos) * distanceScale * uNoiseDropoff;
fragColor = clamp(vec4(newCol.rgb, distA), 0.0, 1.0); // The further away it gets, the less noise gets applied
// The further away it gets, the less noise gets applied
fragColor = vec4(0.0, 0.0, 0.0, randomValue);
// For testing
// if (vertexColor.r != 69420.) {
// fragColor = vec4(
// mod(fixedVPos.x, 1),
// mod(fixedVPos.y, 1),
// mod(fixedVPos.z, 1),
// 1f);
// }
}
@@ -0,0 +1,15 @@
#version 150 core
in vec2 vPosition;
out vec2 TexCoord;
/**
* This is specifically used by application shaders.
* IE post process or pixel transfer shaders, anything that is rendered using a single rectangle.
*/
void main()
{
gl_Position = vec4(vPosition, 1.0, 1.0);
TexCoord = vPosition.xy * 0.5 + 0.5;
}
@@ -0,0 +1,130 @@
#version 150 core
#extension GL_ARB_derivative_control : enable
#define SAMPLE_MAX 64
#define saturate(x) (clamp((x), 0.0, 1.0))
in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D uDepthMap;
uniform int uSampleCount;
uniform float uRadius;
uniform float uStrength;
uniform float uMinLight;
uniform float uBias;
uniform mat4 uInvProj;
uniform mat4 uProj;
uniform float uFadeDistanceInBlocks;
const float EPSILON = 1.e-6;
const float GOLDEN_ANGLE = 2.39996323;
const vec3 MAGIC = vec3(0.06711056, 0.00583715, 52.9829189);
const float PI = 3.1415926538;
const float TAU = PI * 2.0;
vec3 unproject(vec4 pos)
{
return pos.xyz / pos.w;
}
float InterleavedGradientNoise(const in vec2 pixel)
{
float x = dot(pixel, MAGIC.xy);
return fract(MAGIC.z * fract(x));
}
vec3 calcViewPosition(const in vec3 clipPos)
{
vec4 viewPos = uInvProj * vec4(clipPos * 2.0 - 1.0, 1.0);
return viewPos.xyz / viewPos.w;
}
float GetSpiralOcclusion(const in vec2 uv, const in vec3 viewPos, const in vec3 viewNormal)
{
float dither = InterleavedGradientNoise(gl_FragCoord.xy);
float rotatePhase = dither * TAU;
float rStep = uRadius / uSampleCount;
vec2 offset;
float ao = 0.0;
int sampleCount = 0;
float radius = rStep;
for (int i = 0; i < clamp(uSampleCount, 1, SAMPLE_MAX); i++) {
vec2 offset = vec2(
sin(rotatePhase),
cos(rotatePhase)
) * radius;
radius += rStep;
rotatePhase += GOLDEN_ANGLE;
vec3 sampleViewPos = viewPos + vec3(offset, -0.1);
vec3 sampleClipPos = unproject(uProj * vec4(sampleViewPos, 1.0)) * 0.5 + 0.5;
sampleClipPos = saturate(sampleClipPos);
float sampleClipDepth = textureLod(uDepthMap, sampleClipPos.xy, 0.0).r;
if (sampleClipDepth >= 1.0 - EPSILON) continue;
sampleClipPos.z = sampleClipDepth;
sampleViewPos = unproject(uInvProj * vec4(sampleClipPos * 2.0 - 1.0, 1.0));
vec3 diff = sampleViewPos - viewPos;
float sampleDist = length(diff);
vec3 sampleNormal = diff / sampleDist;
float sampleNoLm = max(dot(viewNormal, sampleNormal) - uBias, 0.0);
float aoF = 1.0 - saturate(sampleDist / uRadius);
ao += sampleNoLm * aoF;
sampleCount++;
}
ao /= max(sampleCount, 1);
ao = smoothstep(0.0, uStrength, ao);
return ao * (1.0 - uMinLight);
}
void main()
{
float fragmentDepth = textureLod(uDepthMap, TexCoord, 0).r;
float occlusion = 0.0;
// Do not apply to sky
if (fragmentDepth < 1.0)
{
vec3 viewPos = calcViewPosition(vec3(TexCoord, fragmentDepth));
// fading is done to prevent banding/noise
// at super far distance
float distanceFromCamera = length(viewPos);
float fadeDistance = uFadeDistanceInBlocks;
if (distanceFromCamera < fadeDistance)
{
#ifdef GL_ARB_derivative_control
// Get higher precision derivatives when available
vec3 viewNormal = cross(dFdxFine(viewPos.xyz), dFdyFine(viewPos.xyz));
#else
vec3 viewNormal = cross(dFdx(viewPos.xyz), dFdy(viewPos.xyz));
#endif
viewNormal = normalize(viewNormal);
occlusion = GetSpiralOcclusion(TexCoord, viewPos, viewNormal);
// linearly fade with distance
occlusion *= (fadeDistance - distanceFromCamera) / fadeDistance;
}
else
{
// we're out of range, no need to do any SSAO calculations
occlusion = 0.0;
}
}
fragColor = vec4(vec3(1.0 - occlusion), 1.0);
}
@@ -0,0 +1,78 @@
#version 150 core
in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D gSSAOMap;
uniform sampler2D gDepthMap;
uniform vec2 gViewSize;
uniform int gBlurRadius;
uniform float gNear;
uniform float gFar;
float linearizeDepth(const in float depth) {
return (gNear * gFar) / (depth * (gNear - gFar) + gFar);
}
float Gaussian(const in float sigma, const in float x) {
return exp(-(x*x) / (2.0 * (sigma*sigma)));
}
float BilateralGaussianBlur(const in vec2 texcoord, const in float linearDepth, const in float g_sigmaV) {
float g_sigmaX = 1.6;
float g_sigmaY = 1.6;
int radius = clamp(gBlurRadius, 1, 3);
vec2 pixelSize = 1.0 / gViewSize;
float accum = 0.0;
float total = 0.0;
for (int iy = -radius; iy <= radius; iy++) {
float fy = Gaussian(g_sigmaY, iy);
for (int ix = -radius; ix <= radius; ix++) {
float fx = Gaussian(g_sigmaX, ix);
vec2 sampleTex = texcoord + ivec2(ix, iy) * pixelSize;
float sampleValue = textureLod(gSSAOMap, sampleTex, 0).r;
float sampleDepth = textureLod(gDepthMap, sampleTex, 0).r;
float sampleLinearDepth = linearizeDepth(sampleDepth);
float depthDiff = abs(sampleLinearDepth - linearDepth);
float fv = Gaussian(g_sigmaV, depthDiff);
float weight = fx*fy*fv;
accum += weight * sampleValue;
total += weight;
}
}
if (total <= 1.e-4) return 1.0;
return accum / total;
}
void main()
{
fragColor = vec4(1.0);
float fragmentDepth = textureLod(gDepthMap, TexCoord, 0).r;
// a fragment depth of "1" means the fragment wasn't drawn to,
// we only want to apply SSAO to LODs, not to the sky outside the LODs
if (fragmentDepth < 1)
{
if (gBlurRadius > 0)
{
float fragmentDepthLinear = linearizeDepth(fragmentDepth);
fragColor.a = BilateralGaussianBlur(TexCoord, fragmentDepthLinear, 1.6);
}
else
{
fragColor.a = texelFetch(gSSAOMap, ivec2(gl_FragCoord.xy), 0).r;
}
}
}
@@ -0,0 +1,79 @@
#version 150 core
in uvec4 vPosition;
out vec4 vPos;
in vec4 color;
out vec4 vertexColor;
out vec3 vertexWorldPos;
out float vertexYPos;
uniform bool uIsWhiteWorld;
uniform mat4 uCombinedMatrix;
uniform vec3 uModelOffset;
uniform float uWorldYOffset;
uniform sampler2D uLightMap;
uniform float uMircoOffset;
uniform float uEarthRadius;
/**
* Vertex Shader
*
* author: James Seibel
* author: TomTheFurry
* author: stduhpf
* updated: coolGi
*
* version: 2025-12-22
*/
void main()
{
vPos = vPosition; // This is so it can be passed to the fragment shader
vertexWorldPos = vPosition.xyz + uModelOffset;
vertexYPos = vPosition.y + uWorldYOffset;
uint meta = vPosition.a;
uint mirco = (meta & 0xFF00u) >> 8u; // mirco offset which is a xyz 2bit value
// 0b00 = no offset
// 0b01 = positive offset
// 0b11 = negative offset
// format is: 0b00zzyyxx
float mx = (mirco & 1u)!=0u ? uMircoOffset : 0.0;
mx = (mirco & 2u)!=0u ? -mx : mx;
//float my = (mirco & 4u)!=0u ? uMircoOffset : 0.0;
//my = (mirco & 8u)!=0u ? -my : my;
float mz = (mirco & 16u)!=0u ? uMircoOffset : 0.0;
mz = (mirco & 32u)!=0u ? -mz : mz;
vertexWorldPos.x += mx;
//vertexWorldPos.y += my;
vertexWorldPos.z += mz;
// apply the earth curvature if needed
if (uEarthRadius < -1.0f || uEarthRadius > 1.0f)
{
// vertex transformation logic - stduhpf
float localRadius = uEarthRadius + vertexYPos;
float phi = length(vertexWorldPos.xz) / localRadius;
vertexWorldPos.y += (cos(phi) - 1.0) * localRadius;
vertexWorldPos.xz = vertexWorldPos.xz * sin(phi) / phi;
}
uint lights = meta & 0xFFu;
float skyLight = (float(lights/16u)+0.5) / 16.0;
float blockLight = (mod(float(lights), 16.0)+0.5) / 16.0;
vertexColor = vec4(texture(uLightMap, vec2(skyLight, blockLight)).xyz, 1.0);
if (!uIsWhiteWorld)
{
vertexColor *= color;
}
gl_Position = uCombinedMatrix * vec4(vertexWorldPos, 1.0);
}
@@ -0,0 +1,9 @@
#version 150 core
out vec4 fragColor;
// A test shader that makes everything darker
void main()
{
fragColor = vec4(0., 0., 1., 0.5);
}
@@ -0,0 +1,9 @@
#version 150 core
in vec4 fColor;
out vec4 fragColor;
void main()
{
fragColor = fColor;
}
@@ -0,0 +1,11 @@
#version 150 core
in vec2 vPosition;
in vec4 color;
out vec4 fColor;
void main()
{
gl_Position = vec4(vPosition, 0.0, 1.0);
fColor = color;
}
@@ -0,0 +1,37 @@
CREATE TABLE DhFullData(
DhSectionPos TEXT NOT NULL PRIMARY KEY
-- meta data
,DataDetailLevel TINYINT NULL
,Checksum INT NULL
,DataVersion BIGINT NULL
,WorldGenStep NVARCHAR(32) NULL
,DataType NVARCHAR(48) NULL
,BinaryDataFormatVersion TINYINT NULL
,Data BLOB NULL
,CreatedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC
,LastModifiedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC
);
-- Note: each statement must be separated by the following batch comment line otherwise Java won't run anything after the first query
--batch--
CREATE TABLE DhRenderData(
DhSectionPos TEXT NOT NULL PRIMARY KEY
-- meta data
,DataDetailLevel TINYINT NULL
,Checksum INT NULL
,DataVersion BIGINT NULL
,WorldGenStep NVARCHAR(32) NULL
,DataType NVARCHAR(48) NULL
,BinaryDataFormatVersion TINYINT NULL
,Data BLOB NULL
,CreatedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC
,LastModifiedDateTime DATETIME NOT NULL default CURRENT_TIMESTAMP -- in UTC
);
@@ -0,0 +1,33 @@
ALTER TABLE DhFullData RENAME TO Legacy_FullData_V1;
--batch--
ALTER TABLE Legacy_FullData_V1 ADD COLUMN MigrationFailed BIT NOT NULL DEFAULT 0;
--batch--
CREATE TABLE FullData (
-- compound primary key
DetailLevel TINYINT NOT NULL -- LOD detail level, not section detail level IE 0, 1, 2 not 6, 7, 8
,PosX INT NOT NULL
,PosZ INT NOT NULL
,MinY INT NOT NULL
,DataChecksum INT NOT NULL
,Data BLOB NULL
,ColumnGenerationStep BLOB NULL
,ColumnWorldCompressionMode BLOB NULL
,Mapping BLOB NULL
,DataFormatVersion TINYINT NULL
,CompressionMode TINYINT NULL
,ApplyToParent BIT NULL
,LastModifiedUnixDateTime BIGINT NOT NULL -- in GMT 0
,CreatedUnixDateTime BIGINT NOT NULL -- in GMT 0
,PRIMARY KEY (DetailLevel, PosX, PosZ)
);
@@ -0,0 +1,9 @@
-- this PRAGMA will automatically commit, so we have to disable
-- DH's automatic transactions, otherwise the connection will throw an error
--No Transactions--
-- James ran into some issues where Windows had trouble deleting the Journal file,
-- using TRUNCATE should fix that issue
PRAGMA journal_mode = TRUNCATE;
@@ -0,0 +1,8 @@
-- these PRAGMA's will automatically commit, so we have to disable
-- DH's automatic transactions, otherwise the connection will throw an error
--No Transactions--
pragma journal_mode = WAL;
pragma synchronous = NORMAL;
@@ -0,0 +1,4 @@
-- The render cache was discovered to not speed up LOD loading,
-- so to reduce DB file size it was removed.
drop table DhRenderData;
@@ -0,0 +1,3 @@
-- significantly speeds up parent update handling
create index FullDataUpdatedIndex on FullData (ApplyToParent) where ApplyToParent = 1
@@ -0,0 +1,13 @@
CREATE TABLE ChunkHash(
-- compound primary key
ChunkPosX INT NOT NULL
,ChunkPosZ INT NOT NULL
,ChunkHash INT NOT NULL
,LastModifiedUnixDateTime BIGINT NOT NULL -- in GMT 0
,CreatedUnixDateTime BIGINT NOT NULL -- in GMT 0
,PRIMARY KEY (ChunkPosX, ChunkPosZ)
);
@@ -0,0 +1,16 @@
CREATE TABLE BeaconBeam(
-- compound primary key
BlockPosX INT NOT NULL
,BlockPosY INT NOT NULL
,BlockPosZ INT NOT NULL
,ColorR INT NOT NULL
,ColorG INT NOT NULL
,ColorB INT NOT NULL
,LastModifiedUnixDateTime BIGINT NOT NULL -- in GMT 0
,CreatedUnixDateTime BIGINT NOT NULL -- in GMT 0
,PRIMARY KEY (BlockPosX, BlockPosY, BlockPosZ)
);
@@ -0,0 +1,9 @@
-- Applying to children is needed to fix a bug with N-sized generation.
-- If we don't fill the whole tree with data, it's possible to render empty/incomplete LODs, which looks bad.
alter table FullData add column ApplyToChildren BIT NULL;
--batch--
-- significantly speeds up update handling
create index FullDataApplyToChildrenIndex on FullData (ApplyToChildren) where ApplyToChildren = 1;
@@ -0,0 +1,12 @@
-- storing adjacent data (IE a single line of data on the +X/-X/+Z/-Z axis)
-- allows for significantly reduced render loading times since we only have to
-- handle part of the adjacent data source vs all of it
alter table FullData add column NorthAdjData BLOB NULL;
--batch--
alter table FullData add column SouthAdjData BLOB NULL;
--batch--
alter table FullData add column EastAdjData BLOB NULL;
--batch--
alter table FullData add column WestAdjData BLOB NULL;
@@ -0,0 +1,13 @@
-- This is done to fix a bug where a lot of unnecessary
-- ID mapping data is saved, which significantly reduces
-- loading/deserializing/decompression time
-- delete all data above 0 (max detail)
-- so it can be re-created
delete from FullData where DetailLevel > 0;
--batch--
-- re-downsample all LOD data
update FullData set ApplyToParent = 1;
@@ -0,0 +1,51 @@
### All Sql scripts should be run exactly once per database and old scripts shouldn't be changed. Any necessary schema changes should be done by creating new scripts that modify the existing database.
This system is roughly based on the DbUp library from .NET, for information about DbUp and it's general philosophy please refer to the following doc:
https://dbup.readthedocs.io/en/latest/philosophy-behind-dbup/
<br>
### Adding New Scripts:
New scripts must be added to the "scriptList.txt" file, otherwise they will not be run. <br>
(If anyone has a good way to automatically pull all resource files ending in `.sql` instead, please let us know.)
<br>
### File Naming:
- The first 3 numbers are major scripts.
- The 4th number is for minor/related scripts or if a bug fix needs to be applied between scripts.
- flavor of database the script is for (for now this is just sqlite)
- description of the script
<br>
### Mutli-query Scripts:
When creating a script with multiple queries the queries must be separated with the SQL comment `--batch--` otherwise only the first query will be executed.
Example:
```roomsql
CREATE TABLE TableOne(
DhSectionPos TEXT NOT NULL PRIMARY KEY
,Data BLOB NULL
);
--batch--
CREATE TABLE TableTwo(
DhSectionPos TEXT NOT NULL PRIMARY KEY
,Data BLOB NULL
);
```
### PRAGMA Auto Commits
Certain queries will auto commit after running, specifically certain `PRAGMA` commands. In that case we have to disable DH's automatic transactions by putting `--No Transactions--` somewhere in the file. Otherwise, when the system attempts to commit, it will fail due to the PRAGMA having already committed itself.
Due to how these commands work it's best to only have a single command in the file to prevent confusion and potential database corruption.
```roomsql
--No Transactions--
PRAGMA journal_mode = TRUNCATE;
```
@@ -0,0 +1,12 @@
0010-sqlite-createInitialDataTables.sql
0020-sqlite-createFullDataSourceV2Tables.sql
0030-sqlite-changeTableJournaling.sql
0031-sqlite-useSqliteWalJournaling.sql
0040-sqlite-removeRenderCache.sql
0050-sqlite-addApplyToParentIndex.sql
0060-sqlite-createChunkHashTable.sql
0070-sqlite-createBeaconBeamTable.sql
0080-sqlite-addApplyToChildrenColumn.sql
0090-sqlite-addAdjacentFullDataColumns.sql
0100-sqlite-deleteLowDetailDataForRegen.sql
@@ -1,9 +1,8 @@
package com.seibel.distanthorizons.common;
import com.mojang.brigadier.CommandDispatcher;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
import com.seibel.distanthorizons.common.commands.CommandInitializer;
//import com.seibel.distanthorizons.common.commands.CommandInitializer;
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
import com.seibel.distanthorizons.common.wrappers.gui.DhDebugScreenEntry;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
@@ -22,7 +21,11 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModAccesso
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
import com.seibel.distanthorizons.coreapi.ModInfo;
#if MC_VER <= MC_1_12_2
#else
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.commands.CommandSourceStack;
#endif
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -38,7 +41,7 @@ public abstract class AbstractModInitializer
{
protected static final DhLogger LOGGER = new DhLoggerBuilder().build();
private CommandInitializer commandInitializer;
//private CommandInitializer commandInitializer;
@@ -52,7 +55,7 @@ public abstract class AbstractModInitializer
protected abstract IEventProxy createServerProxy(boolean isDedicated);
protected abstract void initializeModCompat();
protected abstract void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler);
//protected abstract void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler);
protected abstract void subscribeClientStartedEvent(Runnable eventHandler);
protected abstract void subscribeServerStartingEvent(Consumer<MinecraftServer> eventHandler);
@@ -115,8 +118,8 @@ public abstract class AbstractModInitializer
this.initializeModCompat();
LOGGER.info(ModInfo.READABLE_NAME + " server Initialized, adding event subscribers...");
this.commandInitializer = new CommandInitializer();
this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); });
//this.commandInitializer = new CommandInitializer();
//this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandInitializer.initCommands(dispatcher); });
this.subscribeServerStartingEvent(server ->
{
@@ -124,11 +127,11 @@ public abstract class AbstractModInitializer
this.initConfig();
this.postInit();
this.commandInitializer.onServerReady();
//this.commandInitializer.onServerReady();
this.checkForUpdates();
LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.getServerDirectory());
LOGGER.info(ModInfo.READABLE_NAME + " server Initialized at " + server.#if MC_VER <= MC_1_12_2 getDataDirectory() #else getServerDirectory() #endif);
});
}
@@ -12,10 +12,17 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSende
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;
import io.netty.buffer.ByteBufUtil;
#if MC_VER <= MC_1_12_2
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.PacketBuffer;
#else
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
#endif
#if MC_VER <= MC_1_21_10
#if MC_VER <= MC_1_12_2
import net.minecraft.util.ResourceLocation;
#elif MC_VER <= MC_1_21_10
import net.minecraft.resources.ResourceLocation;
#else
import net.minecraft.resources.Identifier;
@@ -31,7 +38,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
.build();
#if MC_VER <= MC_1_20_6
public static final ResourceLocation WRAPPER_PACKET_RESOURCE = new ResourceLocation(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH);
public static final String WRAPPER_PACKET_RESOURCE = ModInfo.RESOURCE_NAMESPACE + ModInfo.WRAPPER_PACKET_PATH;
#elif MC_VER <= MC_1_21_10
public static final ResourceLocation WRAPPER_PACKET_RESOURCE = ResourceLocation.fromNamespaceAndPath(ModInfo.RESOURCE_NAMESPACE, ModInfo.WRAPPER_PACKET_PATH);
#else
@@ -52,14 +59,14 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
@Override
public final void sendToClient(IServerPlayerWrapper serverPlayer, AbstractNetworkMessage message)
{
this.sendToClient((ServerPlayer) serverPlayer.getWrappedMcObject(), message);
this.sendToClient(#if MC_VER <= MC_1_12_2 (EntityPlayerMP) #else (ServerPlayer) #endif serverPlayer.getWrappedMcObject(), message);
}
public abstract void sendToClient(ServerPlayer serverPlayer, AbstractNetworkMessage message);
public abstract void sendToClient(#if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif serverPlayer, AbstractNetworkMessage message);
@Override
public abstract void sendToServer(AbstractNetworkMessage message);
public AbstractNetworkMessage decodeMessage(FriendlyByteBuf in)
public AbstractNetworkMessage decodeMessage(#if MC_VER <= MC_1_12_2 PacketBuffer #else FriendlyByteBuf #endif in)
{
AbstractNetworkMessage message = null;
@@ -100,7 +107,7 @@ public abstract class AbstractPluginPacketSender implements IPluginPacketSender
}
}
public void encodeMessage(FriendlyByteBuf out, AbstractNetworkMessage message)
public void encodeMessage(#if MC_VER <= MC_1_12_2 PacketBuffer #else FriendlyByteBuf #endif out, AbstractNetworkMessage message)
{
// This is intentionally unhandled, because errors related to this are unlikely to appear in wild
Objects.requireNonNull(message);
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.commands;
#if MC_VER > MC_1_12_2
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
@@ -100,3 +101,4 @@ public abstract class AbstractCommand
}
}
#endif
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.commands;
#if MC_VER > MC_1_12_2
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandSourceStack;
@@ -82,3 +83,4 @@ public class CommandInitializer
}
}
#endif
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.commands;
#if MC_VER > MC_1_12_2
import com.mojang.brigadier.arguments.*;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
@@ -151,4 +152,5 @@ public class ConfigCommand extends AbstractCommand
}
}
}
#endif
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.commands;
#if MC_VER > MC_1_12_2
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.seibel.distanthorizons.core.api.internal.SharedApi;
import com.seibel.distanthorizons.core.multiplayer.server.ServerPlayerState;
@@ -42,3 +43,4 @@ public class CrashCommand extends AbstractCommand
}
}
#endif
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.commands;
#if MC_VER > MC_1_12_2
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
import net.minecraft.commands.CommandSourceStack;
@@ -23,3 +24,4 @@ public class DebugCommand extends AbstractCommand
}
}
#endif
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.commands;
#if MC_VER > MC_1_12_2
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
@@ -105,3 +106,4 @@ public class PregenCommand extends AbstractCommand
}
}
#endif
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.commonMixins;
#if MC_VER > MC_1_12_2
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
import com.seibel.distanthorizons.core.config.Config;
@@ -11,16 +12,18 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
#if MC_VER <= MC_1_12_2
#else
import net.minecraft.client.gui.screens.TitleScreen;
#endif
import java.util.ArrayList;
public class DhUpdateScreenBase
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final Minecraft MC = Minecraft.getInstance();
private static final Minecraft MC = Minecraft #if MC_VER <= MC_1_12_2 .getMinecraft() #else .getInstance() #endif;
public static void tryShowUpdateScreenAndRunAutoUpdateStartup(Runnable runnable)
@@ -86,3 +89,4 @@ public class DhUpdateScreenBase
}
}
#endif
@@ -5,14 +5,20 @@ import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
import com.seibel.distanthorizons.core.api.internal.ServerApi;
import com.seibel.distanthorizons.core.api.internal.SharedApi;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
#if MC_VER <= MC_1_12_2
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
#else
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.chunk.ChunkAccess;
#endif
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
public class MixinChunkMapCommon
{
public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable<Boolean> ci)
public static void onChunkSave(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level, #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk #if MC_VER > MC_1_12_2, CallbackInfoReturnable<Boolean> ci #endif)
{
IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level);
@@ -25,7 +31,7 @@ public class MixinChunkMapCommon
// is this chunk being saved to disk?
boolean savingChunkToDisk = ci.getReturnValue();
boolean savingChunkToDisk = #if MC_VER <= MC_1_12_2 true #else ci.getReturnValue() #endif;
// true means a chunk was saved to disk
if (!savingChunkToDisk)
{
@@ -38,7 +44,12 @@ public class MixinChunkMapCommon
// MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks)
// this logic should prevent that from happening
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
#if MC_VER <= MC_1_12_2
if (!chunk.isTerrainPopulated() || !chunk.isLightPopulated())
{
return;
}
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect())
{
return;
@@ -55,8 +66,8 @@ public class MixinChunkMapCommon
// biome validation //
// some chunks may be missing their biomes, which cause issues when attempting to save them
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
if (chunk.getBiomes() == null)
#if MC_VER <= MC_1_17_1
if (chunk.#if MC_VER <= MC_1_12_2 getBiomeArray() #else getBiomes() #endif == null)
{
return;
}
@@ -22,23 +22,28 @@ package com.seibel.distanthorizons.common.util;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
#else
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.LevelAccessor;
#endif
public class ProxyUtil
{
public static ILevelWrapper getLevelWrapper(LevelAccessor level)
public static ILevelWrapper getLevelWrapper(#if MC_VER <= MC_1_12_2 World #else LevelAccessor #endif level)
{
ILevelWrapper levelWrapper;
if (level instanceof ServerLevel)
if (level instanceof #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif)
{
levelWrapper = ServerLevelWrapper.getWrapper((ServerLevel) level);
levelWrapper = ServerLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldServer) #else (ServerLevel) #endif level);
}
else
{
levelWrapper = ClientLevelWrapper.getWrapper((ClientLevel) level);
levelWrapper = ClientLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif level);
}
return levelWrapper;
@@ -26,9 +26,15 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.core.util.math.Mat4f;
#if MC_VER <= MC_1_12_2
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
#else
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.ChunkPos;
#endif
/**
* This class converts to and from Minecraft objects (Ex: Matrix4f)
@@ -47,7 +53,8 @@ public class McObjectConverter
/** 4x4 float matrix converter */
public static Mat4f Convert(
#if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
#if MC_VER <= MC_1_12_2 org.joml.Matrix4f
#elif MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
#elif MC_VER < MC_1_21_6 org.joml.Matrix4f
#else org.joml.Matrix4fc
#endif
@@ -56,21 +63,24 @@ public class McObjectConverter
FloatBuffer buffer = FloatBuffer.allocate(16);
storeMatrix(mcMatrix, buffer);
Mat4f matrix = new Mat4f(buffer);
#if MC_VER < MC_1_19_4
#if MC_VER < MC_1_19_4 && MC_VER > MC_1_12_2
matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it
#endif
return matrix;
}
/** Taken from Minecraft's com.mojang.math.Matrix4f class from 1.18.2 */
private static void storeMatrix(
#if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
#if MC_VER <= MC_1_12_2 org.joml.Matrix4f
#elif MC_VER < MC_1_19_4 com.mojang.math.Matrix4f
#elif MC_VER < MC_1_21_6 org.joml.Matrix4f
#else org.joml.Matrix4fc
#endif
matrix,
FloatBuffer buffer)
{
#if MC_VER < MC_1_19_4
#if MC_VER <= MC_1_12_2
matrix.get(buffer);
#elif MC_VER < MC_1_19_4
matrix.store(buffer);
#else
// Mojang starts to use joml's Matrix4f libary in 1.19.3 so we copy their store method and use it here if its newer than 1.19.3
@@ -94,35 +104,35 @@ public class McObjectConverter
}
static final Direction[] directions;
static final #if MC_VER <= MC_1_12_2 EnumFacing[] #else Direction[] #endif directions;
static final EDhDirection[] lodDirections;
static
{
EDhDirection[] lodDirs = EDhDirection.values();
directions = new Direction[lodDirs.length];
directions = new #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[lodDirs.length];
lodDirections = new EDhDirection[lodDirs.length];
for (EDhDirection lodDir : lodDirs)
{
Direction dir;
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif dir;
switch (lodDir.name().toUpperCase())
{
case "DOWN":
dir = Direction.DOWN;
dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.DOWN;
break;
case "UP":
dir = Direction.UP;
dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP;
break;
case "NORTH":
dir = Direction.NORTH;
dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.NORTH;
break;
case "SOUTH":
dir = Direction.SOUTH;
dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.SOUTH;
break;
case "WEST":
dir = Direction.WEST;
dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.WEST;
break;
case "EAST":
dir = Direction.EAST;
dir = #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.EAST;
break;
default:
dir = null;
@@ -141,7 +151,7 @@ public class McObjectConverter
public static BlockPos Convert(DhBlockPos wrappedPos) { return new BlockPos(wrappedPos.getX(), wrappedPos.getY(), wrappedPos.getZ()); }
public static ChunkPos Convert(DhChunkPos wrappedPos) { return new ChunkPos(wrappedPos.getX(), wrappedPos.getZ()); }
public static Direction Convert(EDhDirection lodDirection) { return directions[lodDirection.ordinal()]; }
public static EDhDirection Convert(Direction direction) { return lodDirections[direction.ordinal()]; }
public static #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif Convert(EDhDirection lodDirection) { return directions[lodDirection.ordinal()]; }
public static EDhDirection Convert(#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction) { return lodDirections[direction.ordinal()]; }
}
@@ -29,7 +29,7 @@ import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
//import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.core.level.IDhLevel;
import com.seibel.distanthorizons.core.level.IDhServerLevel;
import com.seibel.distanthorizons.core.util.LodUtil;
@@ -40,16 +40,26 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
#if MC_VER > MC_1_17_1
import net.minecraft.core.Holder;
#endif
#if MC_VER <= MC_1_12_2
#else
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
#endif
import java.io.IOException;
import java.util.HashSet;
@@ -72,7 +82,8 @@ public class WrapperFactory implements IWrapperFactory
{
if (targetLevel instanceof IDhServerLevel)
{
return new BatchGenerationEnvironment((IDhServerLevel) targetLevel);
//return new BatchGenerationEnvironment((IDhServerLevel) targetLevel);
return null;
}
else
{
@@ -162,25 +173,25 @@ public class WrapperFactory implements IWrapperFactory
// correct number of parameters from the API
// chunk
if (!(objectArray[0] instanceof ChunkAccess))
if (!(objectArray[0] instanceof #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif))
{
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
}
ChunkAccess chunk = (ChunkAccess) objectArray[0];
#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk = (#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif) objectArray[0];
// level / light source
if (!(objectArray[1] instanceof Level))
if (!(objectArray[1] instanceof #if MC_VER <= MC_1_12_2 World #else Level #endif))
{
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
}
// the level is needed for the DH level wrapper...
Level level = (Level) objectArray[1];
#if MC_VER <= MC_1_12_2 World #else Level #endif level = (#if MC_VER <= MC_1_12_2 World #else Level #endif) objectArray[1];
// level wrapper
ILevelWrapper levelWrapper = level.isClientSide()
? ClientLevelWrapper.getWrapper((ClientLevel)level)
: ServerLevelWrapper.getWrapper((ServerLevel)level);
ILevelWrapper levelWrapper = #if MC_VER <= MC_1_12_2 !level.isRemote #else level.isClientSide() #endif
? ClientLevelWrapper.getWrapper((#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif)level)
: ServerLevelWrapper.getWrapper((#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif)level);
return new ChunkWrapper(chunk, levelWrapper);
@@ -203,7 +214,7 @@ public class WrapperFactory implements IWrapperFactory
//#if MC_VER <= MC_1_XX_X
expectedClassNames = new String[]
{
ChunkAccess.class.getName(),
#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif.class.getName(),
"[ServerLevel] or [ClientLevel]" // Classes are not referenced by names to avoid exception when one of them is missing
};
//#endif
@@ -288,12 +299,12 @@ public class WrapperFactory implements IWrapperFactory
{
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
}
if (!(objectArray[0] instanceof BlockState))
if (!(objectArray[0] instanceof #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif))
{
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
}
BlockState blockState = (BlockState) objectArray[0];
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState = (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif) objectArray[0];
return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper);
//#endif
}
@@ -305,7 +316,7 @@ public class WrapperFactory implements IWrapperFactory
{
String[] expectedClassNames;
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
#if MC_VER <= MC_1_17_1
expectedClassNames = new String[] { Biome.class.getName() };
#else
expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" };
@@ -1,5 +1,5 @@
package com.seibel.distanthorizons.common.wrappers.block;
#if MC_VER > MC_1_12_2
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.BlockBiomeWrapperPair;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
@@ -12,11 +12,15 @@ import com.seibel.distanthorizons.core.util.FullDataPointUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import net.minecraft.client.Minecraft;
#if MC_VER <= MC_1_12_2
import net.minecraft.world.biome.Biome;
#else
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.ColorResolver;
import net.minecraft.world.level.biome.Biome;
#endif
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
@@ -335,3 +339,4 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
}
#endif
@@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentMap;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import net.minecraft.world.level.Level;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
@@ -40,18 +39,28 @@ import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.data.BuiltinRegistries;
#else
#elif MC_VER > MC_1_12_2
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
#endif
#if MC_VER <= MC_1_21_10
#if MC_VER > MC_1_12_2
import net.minecraft.world.level.Level;
#endif
#if MC_VER <= MC_1_12_2
import net.minecraft.util.ResourceLocation;
#elif MC_VER <= MC_1_21_10
import net.minecraft.resources.ResourceLocation;
#else
import net.minecraft.resources.Identifier;
#endif
#if MC_VER <= MC_1_12_2
import net.minecraft.world.biome.Biome;
#else
import net.minecraft.world.level.biome.Biome;
#endif
#if MC_VER >= MC_1_18_2
import net.minecraft.world.level.biome.Biomes;
@@ -218,8 +227,10 @@ public class BiomeWrapper implements IBiomeWrapper
// generate the serial string //
#if MC_VER > MC_1_12_2
Level level = (Level)levelWrapper.getWrappedMcObject();
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
#endif
#if MC_VER < MC_1_21_11
ResourceLocation resourceLocation;
@@ -227,7 +238,9 @@ public class BiomeWrapper implements IBiomeWrapper
Identifier resourceLocation;
#endif
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
#if MC_VER <= MC_1_12_2
resourceLocation = this.biome.getRegistryName();
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome);
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
resourceLocation = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).getKey(this.biome.value());
@@ -240,7 +253,7 @@ public class BiomeWrapper implements IBiomeWrapper
if (resourceLocation == null)
{
String biomeName;
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 || MC_VER == MC_1_12_2
biomeName = this.biome.toString();
#else
biomeName = this.biome.value().toString();
@@ -291,10 +304,12 @@ public class BiomeWrapper implements IBiomeWrapper
{
try
{
#if MC_VER > MC_1_12_2
Level level = (Level) levelWrapper.getWrappedMcObject();
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
#endif
BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString, registryAccess);
BiomeDeserializeResult deserializeResult = deserializeBiome(resourceLocationString #if MC_VER > MC_1_12_2, registryAccess #endif);
@@ -323,7 +338,7 @@ public class BiomeWrapper implements IBiomeWrapper
}
}
public static BiomeDeserializeResult deserializeBiome(String resourceLocationString, net.minecraft.core.RegistryAccess registryAccess) throws IOException
public static BiomeDeserializeResult deserializeBiome(String resourceLocationString #if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif) throws IOException
{
// parse the resource location
int separatorIndex = resourceLocationString.indexOf(":");
@@ -354,7 +369,10 @@ public class BiomeWrapper implements IBiomeWrapper
boolean success;
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
#if MC_VER == MC_1_12_2
Biome biome = Biome.REGISTRY.getObject(resourceLocation);
success = (biome != null);
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
success = (biome != null);
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
@@ -29,12 +29,23 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrappe
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
#if MC_VER <= MC_1_12_2
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.SoundType;
import net.minecraft.init.Blocks;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.properties.IProperty;
#else
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.BeaconBeamBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
#endif
import com.seibel.distanthorizons.core.logging.DhLogger;
import java.awt.*;
@@ -44,6 +55,7 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
import net.minecraftforge.fluids.IFluidBlock;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -58,7 +70,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.world.level.EmptyBlockGetter;
#else
#elif MC_VER > MC_1_12_2
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.Level;
import net.minecraft.core.BlockPos;
@@ -67,7 +79,9 @@ import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.core.Holder;
#endif
#if MC_VER <= MC_1_21_10
#if MC_VER <= MC_1_12_2
import net.minecraft.util.ResourceLocation;
#elif MC_VER <= MC_1_21_10
import net.minecraft.resources.ResourceLocation;
#else
import net.minecraft.resources.Identifier;
@@ -84,11 +98,10 @@ public class BlockStateWrapper implements IBlockStateWrapper
// must be defined before AIR, otherwise a null pointer will be thrown
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
public static final ConcurrentHashMap<BlockState, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<#if MC_VER >= MC_1_12_2 IBlockState #else BlockState #endif, BlockStateWrapper> WRAPPER_BY_BLOCK_STATE = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<String, BlockStateWrapper> WRAPPER_BY_RESOURCE_LOCATION = new ConcurrentHashMap<>();
public static final String AIR_STRING = "AIR";
public static final BlockStateWrapper AIR = new BlockStateWrapper(null, null);
public static final String DIRT_RESOURCE_LOCATION_STRING = "minecraft:dirt";
public static final String WATER_RESOURCE_LOCATION_STRING = "minecraft:water";
@@ -102,6 +115,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
"netherite_block"
);
public static final BlockStateWrapper AIR = new BlockStateWrapper(null, null);
public static ObjectOpenHashSet<IBlockStateWrapper> rendererIgnoredBlocks = null;
public static ObjectOpenHashSet<IBlockStateWrapper> rendererIgnoredCaveBlocks = null;
@@ -117,7 +132,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
// properties //
@Nullable
public final BlockState blockState;
public final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState;
/** technically final, but since it requires a method call to generate it can't be marked as such */
private String serialString;
private final int hashCode;
@@ -140,9 +155,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
//==============//
//region
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper)
public static BlockStateWrapper fromBlockState(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper)
{
if (blockState == null || blockState.isAir())
if (blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif)
{
return AIR;
}
@@ -160,14 +175,21 @@ public class BlockStateWrapper implements IBlockStateWrapper
}
}
#if MC_VER <= MC_1_12_2
/**
* Can be faster than {@link BlockStateWrapper#fromBlockState(IBlockState, ILevelWrapper)}
* in cases where the same block state is expected to be referenced multiple times.
*/
#else
/**
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)}
* in cases where the same block state is expected to be referenced multiple times.
*/
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
#endif
public static BlockStateWrapper fromBlockState(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
{
BlockState guessBlockState = (guess == null || guess.isAir()) ? null : (BlockState) guess.getWrappedMcObject();
BlockState inputBlockState = (blockState == null || blockState.isAir()) ? null : blockState;
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState = (guess == null || guess.isAir()) ? null : (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif) guess.getWrappedMcObject();
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState = (blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif) ? null : blockState;
if (guess instanceof BlockStateWrapper
&& guessBlockState == inputBlockState)
@@ -180,7 +202,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
}
}
private BlockStateWrapper(@Nullable BlockState blockState, ILevelWrapper levelWrapper)
private BlockStateWrapper(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper)
{
this.blockState = blockState;
this.serialString = this.serialize(levelWrapper);
@@ -225,12 +247,14 @@ public class BlockStateWrapper implements IBlockStateWrapper
// beacon tint color
Color beaconTintColor = null;
// 1.12.2 doesn't have block for beacon beam
#if MC_VER > MC_1_12_2
if (this.blockState != null
// beacon blocks also show up here, but since they block the beacon beam we don't want their color
&& !this.isBeaconBlock)
{
Block block = this.blockState.getBlock();
if (block instanceof BeaconBeamBlock)
if (block instanceof BeaconBeamBlock )
{
int colorInt;
#if MC_VER <= MC_1_19_4
@@ -242,6 +266,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
beaconTintColor = ColorUtil.toColorObjRGB(colorInt);
}
}
#endif
this.beaconTintColor = beaconTintColor;
@@ -287,7 +312,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
int mcColor = 0;
if (this.blockState != null)
{
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
mcColor = this.blockState.getMaterial().getMaterialMapColor().colorValue;
#elif MC_VER < MC_1_20_1
mcColor = this.blockState.getMaterial().getColor().col;
#else
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
@@ -402,8 +429,12 @@ public class BlockStateWrapper implements IBlockStateWrapper
if (defaultBlockStateToIgnore != AIR)
{
// add all possible blockstates (to account for light blocks with different light values and such)
#if MC_VER <= MC_1_12_2
List<IBlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getBlockState().getValidStates();
#else
List<BlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
for (BlockState blockState : blockStatesToIgnore)
#endif
for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState : blockStatesToIgnore)
{
BlockStateWrapper newBlockToIgnore = BlockStateWrapper.fromBlockState(blockState, levelWrapper);
blockStateWrappers.add(newBlockToIgnore);
@@ -484,7 +515,11 @@ public class BlockStateWrapper implements IBlockStateWrapper
boolean canOcclude = false;
if (this.blockState != null)
{
canOcclude = this.blockState.canOcclude();
#if MC_VER <= MC_1_12_2
canOcclude = this.blockState.isOpaqueCube();
#else
canOcclude = this.blockState.canOcclude();
#endif
}
return canOcclude;
@@ -495,7 +530,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
boolean propagatesSkyLightDown = true;
if (this.blockState != null)
{
#if MC_VER < MC_1_21_3
#if MC_VER <= MC_1_12_2
propagatesSkyLightDown = !this.blockState.isOpaqueCube() && !(this.blockState.getBlock() instanceof BlockLiquid);
#elif MC_VER < MC_1_21_3
propagatesSkyLightDown = this.blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
#else
propagatesSkyLightDown = this.blockState.propagatesSkylightDown();
@@ -509,7 +546,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
@Override
public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; }
public int getLightEmission() { return (this.blockState != null) ? #if MC_VER <= MC_1_12_2 this.blockState.getLightValue() #else this.blockState.getLightEmission() #endif : 0; }
@Override
public String getSerialString() { return this.serialString; }
@@ -541,7 +578,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
@Override
public boolean isAir() { return this.isAir(this.blockState); }
public boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
public boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { return blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif; }
private Boolean blockIsSolid = null;
@Override
@@ -578,7 +615,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
return false;
}
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
return this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock;
#elif MC_VER < MC_1_20_1
return this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty();
#else
return !this.blockState.getFluidState().isEmpty();
@@ -635,7 +674,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
Identifier resourceLocation;
#endif
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
#if MC_VER <= MC_1_12_2
resourceLocation = this.blockState.getBlock().getRegistryName();
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
resourceLocation = Registry.BLOCK.getKey(this.blockState.getBlock());
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(this.blockState.getBlock());
@@ -734,7 +775,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
#endif
Block block;
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
#if MC_VER <= MC_1_12_2
block = Block.REGISTRY.getObject(resourceLocation);
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
block = Registry.BLOCK.get(resourceLocation);
#elif MC_VER == MC_1_18_2 || MC_VER == MC_1_19_2
net.minecraft.core.RegistryAccess registryAccess = level.registryAccess();
@@ -763,11 +806,15 @@ public class BlockStateWrapper implements IBlockStateWrapper
// attempt to find the blockstate from all possibilities
BlockState foundState = null;
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif foundState = null;
if (blockStatePropertiesString != null)
{
#if MC_VER <= MC_1_12_2
List<IBlockState> possibleStateList = block.getBlockState().getValidStates();
#else
List<BlockState> possibleStateList = block.getStateDefinition().getPossibleStates();
for (BlockState possibleState : possibleStateList)
#endif
for (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif possibleState : possibleStateList)
{
String possibleStatePropertiesString = serializeBlockStateProperties(possibleState);
if (possibleStatePropertiesString.equals(blockStatePropertiesString))
@@ -791,7 +838,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
}
}
foundState = block.defaultBlockState();
foundState = #if MC_VER <= MC_1_12_2 block.getDefaultState() #else block.defaultBlockState() #endif;
}
foundWrapper = new BlockStateWrapper(foundState, levelWrapper);
@@ -811,26 +858,36 @@ public class BlockStateWrapper implements IBlockStateWrapper
}
/** used to compare and save BlockStates based on their properties */
private static String serializeBlockStateProperties(BlockState blockState)
private static String serializeBlockStateProperties(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState)
{
// get the property list for this block (doesn't contain this block state's values, just the names and possible values)
java.util.Collection<net.minecraft.world.level.block.state.properties.Property<?>> blockPropertyCollection = blockState.getProperties();
#if MC_VER <= MC_1_12_2
java.util.Collection<IProperty<?>> blockPropertyCollection = blockState.getPropertyKeys();
#else
java.util.Collection<Property<?>> blockPropertyCollection = blockState.getProperties();;
#endif
// 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);
List<#if MC_VER <= MC_1_12_2 IProperty<?> #else Property<?> #endif> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName()));
StringBuilder stringBuilder = new StringBuilder();
for (net.minecraft.world.level.block.state.properties.Property<?> property : sortedBlockPropteryList)
for (#if MC_VER <= MC_1_12_2 IProperty<?> #else Property<?> #endif property : sortedBlockPropteryList)
{
String propertyName = property.getName();
String value = "NULL";
#if MC_VER <= MC_1_12_2
value = blockState.getValue(property).toString();
#else
if (blockState.hasProperty(property))
{
value = blockState.getValue(property).toString();
}
#endif
stringBuilder.append("{");
stringBuilder.append(propertyName).append(RESOURCE_LOCATION_SEPARATOR).append(value);
@@ -858,8 +915,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
String serialString = this.getSerialString().toLowerCase();
if (this.blockState.is(BlockTags.LEAVES)
if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock() instanceof BlockLeaves #else this.blockState.is(BlockTags.LEAVES) #endif
|| serialString.contains("bamboo")
|| serialString.contains("cactus")
|| serialString.contains("chorus_flower")
@@ -868,15 +924,15 @@ public class BlockStateWrapper implements IBlockStateWrapper
{
return EDhApiBlockMaterial.LEAVES;
}
else if (this.blockState.is(Blocks.LAVA))
else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock() == Blocks.LAVA || this.blockState.getBlock() == Blocks.FLOWING_LAVA #else this.blockState.is(Blocks.LAVA) #endif)
{
return EDhApiBlockMaterial.LAVA;
}
else if (this.isLiquid() || this.blockState.is(Blocks.WATER))
else if (this.isLiquid() || #if MC_VER <= MC_1_12_2 this.blockState.getBlock() == Blocks.WATER || this.blockState.getBlock() == Blocks.FLOWING_WATER #else this.blockState.is(Blocks.WATER) #endif)
{
return EDhApiBlockMaterial.WATER;
}
else if (this.blockState.getSoundType() == SoundType.WOOD
else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock().getSoundType() #else this.blockState.getSoundType() #endif == SoundType.WOOD
|| serialString.contains("root")
#if MC_VER >= MC_1_19_4
|| this.blockState.getSoundType() == SoundType.CHERRY_WOOD
@@ -885,7 +941,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
{
return EDhApiBlockMaterial.WOOD;
}
else if (this.blockState.getSoundType() == SoundType.METAL
else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock().getSoundType() #else this.blockState.getSoundType() #endif == SoundType.METAL
#if MC_VER >= MC_1_19_2
|| this.blockState.getSoundType() == SoundType.COPPER
#endif
@@ -936,7 +992,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
{
return EDhApiBlockMaterial.TERRACOTTA;
}
else if (this.blockState.is(BlockTags.BASE_STONE_NETHER))
else if (#if MC_VER <= MC_1_12_2 this.blockState.getBlock() == Blocks.NETHERRACK #else this.blockState.is(BlockTags.BASE_STONE_NETHER) #endif)
{
return EDhApiBlockMaterial.NETHER_STONE;
}
@@ -945,7 +1001,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
{
return EDhApiBlockMaterial.STONE;
}
else if (this.blockState.getLightEmission() > 0)
else if (#if MC_VER <= MC_1_12_2 this.blockState.getLightValue() #else this.blockState.getLightEmission() #endif > 0)
{
return EDhApiBlockMaterial.ILLUMINATED;
}
@@ -26,24 +26,33 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
import com.seibel.distanthorizons.core.util.ColorUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
#if MC_VER <= MC_1_12_2
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.*;
#else
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.SlabType;
#endif
#if MC_VER >= MC_1_19_2
import net.minecraft.util.RandomSource;
#else
import java.util.Random;
import java.util.*;
#endif
import net.minecraft.world.level.block.state.BlockState;
import com.seibel.distanthorizons.core.logging.DhLogger;
import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
#if MC_VER < MC_1_21_5
@@ -51,6 +60,15 @@ import java.util.concurrent.locks.ReentrantLock;
import net.minecraft.client.renderer.block.model.BlockModelPart;
#endif
#if MC_VER <= MC_1_12_2
/**
* This stores and calculates the colors
* the given {@link IBlockState} should have based
* on the given {@link IClientLevelWrapper}.
*
* @see ColorUtil
*/
#else
/**
* This stores and calculates the colors
* the given {@link BlockState} should have based
@@ -58,14 +76,15 @@ import net.minecraft.client.renderer.block.model.BlockModelPart;
*
* @see ColorUtil
*/
#endif
public class ClientBlockStateColorCache
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final Minecraft MC = Minecraft.getInstance();
private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
private static final HashSet<BlockState> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>();
private static final HashSet<BlockState> BROKEN_BLOCK_STATES = new HashSet<>();
private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>();
private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BROKEN_BLOCK_STATES = new HashSet<>();
/**
* Methods using MC's "RandomSource" object aren't thread safe <br>
@@ -79,15 +98,15 @@ public class ClientBlockStateColorCache
/** This is the order each direction on a block is processed when attempting to get the texture/color */
private static final @Nullable Direction[] COLOR_RESOLUTION_DIRECTION_ORDER =
{
Direction.UP,
private static final @Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[] COLOR_RESOLUTION_DIRECTION_ORDER =
{
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP,
null, // null represents "unculled" faces, IE the top of farmland
Direction.NORTH,
Direction.EAST,
Direction.WEST,
Direction.SOUTH,
Direction.DOWN
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.NORTH,
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.EAST,
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.WEST,
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.SOUTH,
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.DOWN
};
private static final int FLOWER_COLOR_SCALE = 5;
@@ -102,7 +121,7 @@ public class ClientBlockStateColorCache
#endif
private final IClientLevelWrapper clientLevelWrapper;
private final BlockState blockState;
private final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState;
private final BlockStateWrapper blockStateWrapper;
private boolean isColorResolved = false;
@@ -174,8 +193,10 @@ public class ClientBlockStateColorCache
0.93011117f, 0.9386859f, 0.9473069f, 0.9559735f, 0.9646866f, 0.9734455f, 0.98225087f, 0.9911022f, 1.0f
};
#if MC_VER > MC_1_12_2
private static final ThreadLocal<TintWithoutLevelOverrider> TintWithoutLevelOverrideGetter = ThreadLocal.withInitial(() -> new TintWithoutLevelOverrider());
private static final ThreadLocal<TintGetterOverride> TintOverrideGetter = ThreadLocal.withInitial(() -> new TintGetterOverride());
#endif
@@ -183,7 +204,7 @@ public class ClientBlockStateColorCache
// constructor //
//=============//
public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper)
public ClientBlockStateColorCache(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, IClientLevelWrapper clientLevelWrapper)
{
this.blockState = blockState;
this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper);
@@ -210,17 +231,17 @@ public class ClientBlockStateColorCache
// getQuads() isn't thread safe so we need to put this logic in a lock
RESOLVE_LOCK.lock();
if (this.blockState.getFluidState().isEmpty())
if (#if MC_VER <= MC_1_12_2 !this.blockState.getMaterial().isLiquid() #else this.blockState.getFluidState().isEmpty() #endif)
{
// look for the first non-empty direction
List<BakedQuad> quads = null;
for (Direction direction : COLOR_RESOLUTION_DIRECTION_ORDER)
for (#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction : COLOR_RESOLUTION_DIRECTION_ORDER)
{
quads = this.getQuadsForDirection(direction);
if (quads != null && !quads.isEmpty()
&& !(
this.blockState.getBlock() instanceof RotatedPillarBlock
&& direction == Direction.UP
this.blockState.getBlock() instanceof #if MC_VER <= MC_1_12_2 BlockRotatedPillar #else RotatedPillarBlock #endif
&& direction == #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP
)
)
{
@@ -239,7 +260,7 @@ public class ClientBlockStateColorCache
{
BakedQuad firstQuad = quads.get(0);
this.needPostTinting = firstQuad.isTinted();
this.needPostTinting = firstQuad.#if MC_VER <= MC_1_12_2 hasTintIndex() #else isTinted() #endif;
#if MC_VER <= MC_1_21_4
this.tintIndex = firstQuad.getTintIndex();
#else
@@ -248,7 +269,7 @@ public class ClientBlockStateColorCache
#if MC_VER < MC_1_17_1
this.baseColor = calculateColorFromTexture(
firstQuad.sprite,
firstQuad.#if MC_VER <= MC_1_12_2 getSprite() #else sprite #endif,
EColorMode.getColorMode(this.blockState.getBlock()));
#elif MC_VER < MC_1_21_5
this.baseColor = calculateColorFromTexture(
@@ -288,20 +309,31 @@ public class ClientBlockStateColorCache
@Nullable
private List<BakedQuad> getUnculledQuads() { return this.getQuadsForDirection(null); }
@Nullable
private List<BakedQuad> getQuadsForDirection(@Nullable Direction direction)
private List<BakedQuad> getQuadsForDirection(@Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction)
{
BlockState effectiveBlockState = this.blockState;
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif effectiveBlockState = this.blockState;
// if this block is a slab, use it's double variant so we can get the top face,
// otherwise the color will use the side, which isn't as accurate
// 1.12.2 doesn't have SlabType as property
#if MC_VER > MC_1_12_2
if (this.blockState.getBlock() instanceof SlabBlock)
{
effectiveBlockState = this.blockState.setValue( SlabBlock.TYPE, SlabType.DOUBLE );
effectiveBlockState = this.blockState.setValue(SlabBlock.TYPE, SlabType.DOUBLE);
}
#endif
List<BakedQuad> quads;
#if MC_VER < MC_1_21_5
#if MC_VER <= MC_1_12_2
try {
quads = MC.getBlockRendererDispatcher().getModelForState(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM.nextLong());
}
catch (Exception e)
{
quads = Collections.emptyList();
}
#elif MC_VER < MC_1_21_5
quads = MC.getModelManager().getBlockModelShaper().
getBlockModel(effectiveBlockState).getQuads(effectiveBlockState, direction, RANDOM);
#else
@@ -347,10 +379,18 @@ public class ClientBlockStateColorCache
//_ OpenGL RGBA format Java Order: 0xAA BB GG RR
tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v);
#if MC_VER <= MC_1_12_2
int b = (tempColor & 0x000000FF);
int g = (tempColor & 0x0000FF00) >>> 8;
int r = (tempColor & 0x00FF0000) >>> 16;
int a = (tempColor & 0xFF000000) >>> 24;
#else
int r = (tempColor & 0x000000FF);
int g = (tempColor & 0x0000FF00) >>> 8;
int b = (tempColor & 0x00FF0000) >>> 16;
int a = (tempColor & 0xFF000000) >>> 24;
#endif
int scale = 1;
if (colorMode == EColorMode.Leaves)
{
@@ -415,7 +455,9 @@ public class ClientBlockStateColorCache
}
private static int getTextureWidth(TextureAtlasSprite texture)
{
#if MC_VER < MC_1_19_4
#if MC_VER <= MC_1_12_2
return texture.getIconWidth();
#elif MC_VER < MC_1_19_4
return texture.getWidth();
#else
return texture.contents().width();
@@ -423,7 +465,9 @@ public class ClientBlockStateColorCache
}
private static int getTextureHeight(TextureAtlasSprite texture)
{
#if MC_VER < MC_1_19_4
#if MC_VER <= MC_1_12_2
return texture.getIconHeight();
#elif MC_VER < MC_1_19_4
return texture.getHeight();
#else
return texture.contents().height();
@@ -457,8 +501,12 @@ public class ClientBlockStateColorCache
private int getParticleIconColor()
{
return calculateColorFromTexture(
Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(this.blockState),
EColorMode.getColorMode(this.blockState.getBlock()));
#if MC_VER <= MC_1_12_2
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(this.blockState),
#else
Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(this.blockState),
#endif
EColorMode.getColorMode(this.blockState.getBlock()));
}
@@ -486,6 +534,37 @@ public class ClientBlockStateColorCache
int tintColor = -1;
try
{
// 1.12.2 doesn't have BlockAndTintGetter -> get tintColor from biome
#if MC_VER <= MC_1_12_2
WorldClient world = (WorldClient) this.clientLevelWrapper.getWrappedMcObject();
BlockPos mcPos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ());
Block block = this.blockState.getBlock();
if (block instanceof BlockGrass || block instanceof BlockBush)
{
tintColor = biomeWrapper.biome.getGrassColorAtPos(mcPos);
}
else if (block instanceof BlockLeaves)
{
tintColor = biomeWrapper.biome.getFoliageColorAtPos(mcPos);
}
else if (block instanceof BlockLiquid) // We don't want lava to fall into the else block
{
if(block == Blocks.WATER || block == Blocks.FLOWING_WATER)
{
tintColor = biomeWrapper.biome.getWaterColor();
}
}
else
{
BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
tintColor = blockColors.colorMultiplier(blockState, world, mcPos, this.tintIndex);
if (tintColor == -1)
{
tintColor = blockColors.getColor(blockState, world, mcPos);
}
}
#else
// try to use the fast tint getter logic first
if (!BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
{
@@ -536,6 +615,7 @@ public class ClientBlockStateColorCache
this.tintIndex);
}
}
#endif
}
catch (Exception e)
{
@@ -576,15 +656,15 @@ public class ClientBlockStateColorCache
static EColorMode getColorMode(Block block)
{
if (block instanceof LeavesBlock)
if (block instanceof #if MC_VER <= MC_1_12_2 BlockLeaves #else LeavesBlock #endif)
{
return Leaves;
}
if (block instanceof FlowerBlock)
if (block instanceof #if MC_VER <= MC_1_12_2 BlockFlower #else FlowerBlock #endif)
{
return Flower;
}
if (block.toString().contains("glass"))
if (block.toString().toLowerCase().contains("glass"))
{
return Glass;
}
@@ -37,7 +37,10 @@ public class TextureAtlasSpriteWrapper
{
public static int getPixelRGBA(TextureAtlasSprite sprite, int frameIndex, int x, int y)
{
#if MC_VER < MC_1_17_1
#if MC_VER <= MC_1_12_2
int[][] frameData = sprite.getFrameTextureData(frameIndex);
return frameData[0][y * sprite.getIconWidth() + x];
#elif MC_VER < MC_1_17_1
return sprite.mainImage[0].getPixelRGBA(
x + sprite.framesX[frameIndex] * sprite.getWidth(),
y + sprite.framesY[frameIndex] * sprite.getHeight());
@@ -18,7 +18,7 @@
*/
package com.seibel.distanthorizons.common.wrappers.block;
#if MC_VER > MC_1_12_2
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import net.minecraft.core.BlockPos;
@@ -180,3 +180,4 @@ public class TintGetterOverride extends AbstractDhTintGetter
}
#endif
@@ -18,7 +18,7 @@
*/
package com.seibel.distanthorizons.common.wrappers.block;
#if MC_VER > MC_1_12_2
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import net.minecraft.core.BlockPos;
@@ -88,3 +88,4 @@ public class TintWithoutLevelOverrider extends AbstractDhTintGetter
#endif
}
#endif
@@ -33,10 +33,18 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWr
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
#if MC_VER <= MC_1_12_2
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
#else
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.levelgen.Heightmap;
#endif
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -67,9 +75,9 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.LevelChunkSection;
#endif
#if MC_VER <= MC_1_20_4
#if MC_VER <= MC_1_20_4 && MC_VER > MC_1_12_2
import net.minecraft.world.level.chunk.ChunkStatus;
#else
#elif MC_VER > MC_1_12_2
import net.minecraft.world.level.chunk.status.ChunkStatus;
#endif
@@ -87,7 +95,7 @@ public class ChunkWrapper implements IChunkWrapper
private static boolean heightmapThreadWarningLogged = false;
private final ChunkAccess chunk;
private final #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk;
private final DhChunkPos chunkPos;
private final ILevelWrapper wrappedLevel;
@@ -118,7 +126,7 @@ public class ChunkWrapper implements IChunkWrapper
* fast since it will be called frequently on the MC
* server thread and a slow method will cause server lag.
*/
public ChunkWrapper(ChunkAccess chunk, ILevelWrapper wrappedLevel)
public ChunkWrapper(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk, ILevelWrapper wrappedLevel)
{
this.chunk = chunk;
this.wrappedLevel = wrappedLevel;
@@ -136,7 +144,7 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public int getHeight() { return getHeight(this.chunk); }
public static int getHeight(ChunkAccess chunk)
public static int getHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk)
{
#if MC_VER < MC_1_17_1
return 255;
@@ -147,7 +155,7 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public int getInclusiveMinBuildHeight() { return getInclusiveMinBuildHeight(this.chunk); }
public static int getInclusiveMinBuildHeight(ChunkAccess chunk)
public static int getInclusiveMinBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk)
{
#if MC_VER < MC_1_17_1
return 0;
@@ -160,9 +168,11 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public int getExclusiveMaxBuildHeight() { return getExclusiveMaxBuildHeight(this.chunk); }
public static int getExclusiveMaxBuildHeight(ChunkAccess chunk)
public static int getExclusiveMaxBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk)
{
#if MC_VER < MC_1_21_3
#if MC_VER <= MC_1_12_2
return 256;
#elif MC_VER < MC_1_21_3
return chunk.getMaxBuildHeight();
#else
// +1 since Minecraft made the max value inclusive
@@ -183,7 +193,11 @@ public class ChunkWrapper implements IChunkWrapper
this.minNonEmptyHeight = this.getInclusiveMinBuildHeight();
// determine the lowest empty section (bottom up)
#if MC_VER <= MC_1_12_2
ExtendedBlockStorage[] sections = this.chunk.getBlockStorageArray();
#else
LevelChunkSection[] sections = this.chunk.getSections();
#endif
for (int index = 0; index < sections.length; index++)
{
if (sections[index] == null)
@@ -215,7 +229,11 @@ public class ChunkWrapper implements IChunkWrapper
this.maxNonEmptyHeight = this.getExclusiveMaxBuildHeight();
// determine the highest empty section (top down)
#if MC_VER <= MC_1_12_2
ExtendedBlockStorage[] sections = this.chunk.getBlockStorageArray();
#else
LevelChunkSection[] sections = this.chunk.getSections();
#endif
for (int index = sections.length-1; index >= 0; index--)
{
// update at each position to fix using the max height if the chunk is empty
@@ -235,11 +253,9 @@ public class ChunkWrapper implements IChunkWrapper
return this.maxNonEmptyHeight;
}
private static boolean isChunkSectionEmpty(LevelChunkSection section)
private static boolean isChunkSectionEmpty(#if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section)
{
#if MC_VER == MC_1_16_5
return section.isEmpty();
#elif MC_VER == MC_1_17_1
#if MC_VER <= MC_1_17_1
return section.isEmpty();
#else
return section.hasOnlyAir();
@@ -317,7 +333,11 @@ public class ChunkWrapper implements IChunkWrapper
// will be null if we want to use MC heightmaps
if (this.solidHeightMap == null)
{
#if MC_VER <= MC_1_12_2
return this.chunk.getHeightValue(xRel, zRel);
#else
return this.chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.WORLD_SURFACE).getFirstAvailable(xRel, zRel);
#endif
}
else
{
@@ -332,19 +352,26 @@ public class ChunkWrapper implements IChunkWrapper
if (this.lightBlockingHeightMap == null)
{
#if MC_VER <= MC_1_12_2
return this.chunk.getHeightValue(xRel, zRel);
#else
return this.chunk.getOrCreateHeightmapUnprimed(Heightmap.Types.MOTION_BLOCKING).getFirstAvailable(xRel, zRel);
#endif
}
else
{
return this.lightBlockingHeightMap[xRel][zRel];
}
}
}
@Override
public IBiomeWrapper getBiome(int relX, int relY, int relZ)
{
#if MC_VER < MC_1_17_1
#if MC_VER <= MC_1_12_2
World world = (World) this.wrappedLevel.getWrappedMcObject();
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiome(new BlockPos(relX, relY, relZ), world.getBiomeProvider()), wrappedLevel);
#elif MC_VER < MC_1_17_1
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome(
relX >> 2, relY >> 2, relZ >> 2),
this.wrappedLevel);
@@ -352,10 +379,6 @@ public class ChunkWrapper implements IChunkWrapper
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome(
QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ)),
this.wrappedLevel);
#elif MC_VER < MC_1_18_2
return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome(
QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ)),
this.wrappedLevel);
#else
//Now returns a Holder<Biome> instead of Biome
return BiomeWrapper.getBiomeWrapper(this.chunk.getNoiseBiome(
@@ -371,9 +394,13 @@ public class ChunkWrapper implements IChunkWrapper
BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get();
#if MC_VER <= MC_1_12_2
blockPos.setPos(relX, relY, relZ);
#else
blockPos.setX(relX);
blockPos.setY(relY);
blockPos.setZ(relZ);
#endif
try
{
@@ -396,9 +423,13 @@ public class ChunkWrapper implements IChunkWrapper
this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
BlockPos.MutableBlockPos pos = (BlockPos.MutableBlockPos)mcBlockPos.getWrappedMcObject();
#if MC_VER <= MC_1_12_2
pos.setPos(relX, relY, relZ);
#else
pos.setX(relX);
pos.setY(relY);
pos.setZ(relZ);
#endif
try
{
@@ -508,8 +539,9 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public DhChunkPos getChunkPos() { return this.chunkPos; }
public ChunkAccess getChunk() { return this.chunk; }
public #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif getChunk() { return this.chunk; }
#if MC_VER > MC_1_12_2
public void trySetStatus(ChunkStatus status) { trySetStatus(this.getChunk(), status); }
/** does nothing if the chunk object doesn't support setting it's status */
public static void trySetStatus(ChunkAccess chunk, ChunkStatus status)
@@ -533,15 +565,16 @@ public class ChunkWrapper implements IChunkWrapper
return chunk.getPersistedStatus();
#endif
}
#endif
@Override
public int getMaxBlockX() { return this.chunk.getPos().getMaxBlockX(); }
public int getMaxBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXEnd() #else getMaxBlockX() #endif; }
@Override
public int getMaxBlockZ() { return this.chunk.getPos().getMaxBlockZ(); }
public int getMaxBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZEnd() #else getMaxBlockZ() #endif; }
@Override
public int getMinBlockX() { return this.chunk.getPos().getMinBlockX(); }
public int getMinBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXStart() #else getMinBlockX() #endif; }
@Override
public int getMinBlockZ() { return this.chunk.getPos().getMinBlockZ(); }
public int getMinBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZStart() #else getMinBlockZ() #endif; }
@@ -624,8 +657,23 @@ public class ChunkWrapper implements IChunkWrapper
{
this.blockLightPosList = new ArrayList<>();
#if MC_VER < MC_1_20_1
//1.12.2 doesn't store lights we must bruteforce it
#if MC_VER <= MC_1_12_2
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
for (int y = 0; y < 256; y++)
{
IBlockState blockState = this.chunk.getBlockState(x, y, z);
if (blockState.getLightValue() > 0)
{
this.blockLightPosList.add(new DhBlockPos(this.chunk.getPos().getXStart() + x, y, this.chunk.getPos().getZStart() + z));
}
}
}
}
#elif MC_VER < MC_1_20_1
this.chunk.getLights().forEach((blockPos) ->
{
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
@@ -17,7 +17,6 @@ import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapp
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.config.ConfigHandler;
import com.seibel.distanthorizons.core.config.types.*;
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition;
import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity;
@@ -28,6 +27,14 @@ import com.seibel.distanthorizons.core.util.AnnotationUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting;
#else
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
@@ -38,12 +45,14 @@ import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import com.mojang.blaze3d.platform.InputConstants;
#endif
import com.seibel.distanthorizons.core.logging.DhLogger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
#elif MC_VER < MC_1_20_1
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiComponent;
#else
@@ -54,15 +63,14 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.narration.NarratableEntry;
#endif
#if MC_VER <= MC_1_21_10
#if MC_VER <= MC_1_12_2
import net.minecraft.util.ResourceLocation;
#elif MC_VER <= MC_1_21_10
import net.minecraft.resources.ResourceLocation;
#else
import net.minecraft.resources.Identifier;
#endif
import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.platform.InputConstants;
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable;
@@ -122,7 +130,7 @@ public class ClassicConfigGUI
//==============//
/** if you want to get this config gui's screen call this */
public static Screen getScreen(Screen parent, String category)
public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category)
{ return new DhConfigScreen(parent, category); }
private static class DhConfigScreen extends DhScreen
@@ -132,12 +140,12 @@ public class ClassicConfigGUI
private static final String TRANSLATION_PREFIX = ModInfo.ID + ".config.";
private final Screen parent;
private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent;
private final String category;
private ConfigListWidget configListWidget;
private boolean reload = false;
private Button doneButton;
private #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif doneButton;
@@ -145,7 +153,7 @@ public class ClassicConfigGUI
// constructor //
//=============//
protected DhConfigScreen(Screen parent, String category)
protected DhConfigScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category)
{
super(Translatable(
LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
@@ -158,7 +166,11 @@ public class ClassicConfigGUI
@Override
#if MC_VER <= MC_1_12_2
public void updateScreen() { super.updateScreen(); }
#else
public void tick() { super.tick(); }
#endif
@@ -167,15 +179,20 @@ public class ClassicConfigGUI
//==================//
@Override
#if MC_VER <= MC_1_12_2
public void initGui()
#else
protected void init()
#endif
{
super.init();
super.#if MC_VER <= MC_1_12_2 initGui(); #else init(); #endif
if (!this.reload)
{
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
}
// Changelog button
#if MC_VER > MC_1_12_2
if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()
// we only have changelogs for stable builds
&& !ModInfo.IS_DEV_BUILD)
@@ -213,6 +230,7 @@ public class ClassicConfigGUI
Translatable(ModInfo.ID + ".updater.title")
));
}
#endif
// back button
@@ -222,7 +240,11 @@ public class ClassicConfigGUI
(button) ->
{
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
#if MC_VER <= MC_1_12_2
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
#else
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
#endif
}));
// done/close button
@@ -233,19 +255,25 @@ public class ClassicConfigGUI
(button) ->
{
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
#if MC_VER <= MC_1_12_2
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
#else
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
#endif
}));
this.configListWidget = new ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
this.configListWidget = new ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width * 2, this.height, 32, 32, 25);
#if MC_VER > MC_1_12_2
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
if (this.minecraft != null && this.minecraft.level != null)
{
this.configListWidget.setRenderBackground(false);
}
#endif
this.addWidget(this.configListWidget);
#endif
for (AbstractConfigBase<?> configEntry : ConfigHandler.INSTANCE.configBaseList)
{
@@ -408,10 +436,25 @@ public class ClassicConfigGUI
private static void setupBooleanMenuOption(ConfigEntry<Boolean> booleanConfigEntry)
{
// 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);
#endif
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue);
#if MC_VER <= MC_1_12_2
configGuiInfo.buttonOptionMap =
new AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>>(
(button) ->
{
button.enabled = !booleanConfigEntry.apiIsOverriding();
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText();
}, func);
#else
configGuiInfo.buttonOptionMap =
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
(button) ->
@@ -421,6 +464,7 @@ public class ClassicConfigGUI
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
button.setMessage(func.apply(booleanConfigEntry.get()));
}, func);
#endif
}
private static void setupEnumMenuOption(ConfigEntry<Enum<?>> enumConfigEntry, Class<? extends Enum<?>> enumClass)
{
@@ -428,20 +472,20 @@ public class ClassicConfigGUI
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue);
Function<Object, Component> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
Function<Object, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
configGuiInfo.buttonOptionMap =
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
new AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function<Object, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif>>(
(button) ->
{
// get the currently selected enum and enum index
int startingIndex = enumList.indexOf(enumConfigEntry.get());
Enum<?> enumValue = enumList.get(startingIndex);
boolean shiftPressed =
InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT)
|| InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT);
#if MC_VER <= MC_1_12_2
boolean shiftPressed = GuiScreen.isShiftKeyDown();
#else
boolean shiftPressed = InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT);
#endif
// move forward or backwards depending on if the shift key is pressed
int index = shiftPressed ? startingIndex-1 : startingIndex+1;
@@ -483,9 +527,13 @@ public class ClassicConfigGUI
enumConfigEntry.uiSetWithoutSaving(enumValue);
#if MC_VER <= MC_1_12_2
button.enabled = !enumConfigEntry.apiIsOverriding();
button.displayString = getEnumTranslatableFunc.apply(enumConfigEntry.get()).getFormattedText();
#else
button.active = !enumConfigEntry.apiIsOverriding();
button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get()));
#endif
}, getEnumTranslatableFunc);
}
@@ -502,11 +550,15 @@ public class ClassicConfigGUI
// reset button //
//==============//
Button.OnPress btnAction = (button) ->
#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif btnAction = (button) ->
{
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
this.reload = true;
Objects.requireNonNull(this.minecraft).setScreen(this);
#if MC_VER <= MC_1_12_2
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
#else
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
#endif
};
int resetButtonPosX = this.width
@@ -514,20 +566,29 @@ public class ClassicConfigGUI
- ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
int resetButtonPosZ = 0;
Button resetButton = MakeBtn(
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif resetButton = MakeBtn(
#if MC_VER <= MC_1_12_2
Translatable("distanthorizons.general.reset").setStyle(new Style().setColor(TextFormatting.RED)),
#else
Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED),
#endif
resetButtonPosX, resetButtonPosZ,
ConfigScreenConfigs.RESET_BUTTON_WIDTH, ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
btnAction);
if (configEntry.apiIsOverriding())
{
#if MC_VER <= MC_1_12_2
resetButton.enabled = false;
resetButton.displayString = Translatable("distanthorizons.general.apiOverride").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText();
#else
resetButton.active = false;
resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY));
#endif
}
else
{
resetButton.active = true;
resetButton.#if MC_VER <= MC_1_12_2 enabled #else active #endif = true;
}
@@ -536,7 +597,7 @@ public class ClassicConfigGUI
// option field //
//==============//
Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
int optionFieldPosX = this.width
- ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
@@ -549,20 +610,20 @@ public class ClassicConfigGUI
{
// enum/multi option input button
Map.Entry<Button.OnPress, Function<Object, Component>> widget = configGuiInfo.buttonOptionMap;
Map.Entry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function<Object, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif>> widget = configGuiInfo.buttonOptionMap;
if (configEntry.getType().isEnum())
{
widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString()));
}
Button button = MakeBtn(
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button = MakeBtn(
widget.getValue().apply(configEntry.get()),
optionFieldPosX, optionFieldPosZ,
ConfigScreenConfigs.OPTION_FIELD_WIDTH, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
widget.getKey());
// deactivate the button if the API is overriding it
button.active = !configEntry.apiIsOverriding();
button.#if MC_VER <= MC_1_12_2 enabled #else active #endif = !configEntry.apiIsOverriding();
this.configListWidget.addButton(this, configEntry,
@@ -577,15 +638,17 @@ public class ClassicConfigGUI
{
// text box input
EditBox widget = new EditBox(this.font,
#if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif widget = new #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif(
#if MC_VER <= MC_1_12_2 0, #endif
#if MC_VER <= MC_1_12_2 this.fontRenderer #else this.font #endif,
optionFieldPosX, optionFieldPosZ,
ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
Translatable(""));
widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
widget.insertText(String.valueOf(configEntry.get()));
ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT
#if MC_VER > MC_1_12_2 ,Translatable("") #endif );
widget.#if MC_VER <= MC_1_12_2 setMaxStringLength(3_000_000); #else setMaxLength(3_000_000); #endif // hopefully 3 million characters should be enough for any normal use-case, lol
widget.#if MC_VER <= MC_1_12_2 setText #else insertText #endif (String.valueOf(configEntry.get()));
Predicate<String> processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton);
widget.setFilter(processor);
widget.#if MC_VER <= MC_1_12_2 setValidator(processor::test); #else setFilter(processor); #endif
this.configListWidget.addButton(this, configEntry, widget, resetButton, null, textComponent);
@@ -601,18 +664,22 @@ public class ClassicConfigGUI
{
ConfigCategory configCategory = (ConfigCategory) configType;
Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
int categoryPosX = this.width - ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
int categoryPosZ = this.height - ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored
Button widget = MakeBtn(textComponent,
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent,
categoryPosX, categoryPosZ,
ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
((button) ->
{
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
#if MC_VER <= MC_1_12_2
Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
#else
Objects.requireNonNull(this.minecraft).setScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
#endif
}));
this.configListWidget.addButton(this, configType, widget, null, null, null);
@@ -627,11 +694,11 @@ public class ClassicConfigGUI
{
ConfigUIButton configUiButton = (ConfigUIButton) configType;
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
int buttonPosX = this.width - ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
Button widget = MakeBtn(textComponent,
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent,
buttonPosX, this.height - 28,
ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
(button) -> ((ConfigUIButton) configType).runAction());
@@ -648,7 +715,7 @@ public class ClassicConfigGUI
{
ConfigUIComment configUiComment = (ConfigUIComment) configType;
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
if (configUiComment.parentConfigPath != null)
{
textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath);
@@ -665,7 +732,7 @@ public class ClassicConfigGUI
{
if (configType instanceof ConfigUISpacer)
{
Button spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"),
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"),
10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1)
1, 1,
(button) -> {});
@@ -690,7 +757,7 @@ public class ClassicConfigGUI
return false;
}
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
private #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory());}
@@ -700,23 +767,31 @@ public class ClassicConfigGUI
//===========//
@Override
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
public void drawScreen(int mouseX, int mouseY, float delta)
#elif MC_VER < MC_1_20_1
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
#else
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
#endif
{
#if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function
#if MC_VER <= MC_1_12_2
this.drawDefaultBackground();
#elif MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function
this.renderBackground(matrices); // Renders background
#else
super.render(matrices, mouseX, mouseY, delta);
#endif
this.configListWidget.render(matrices, mouseX, mouseY, delta); // Render buttons
this.configListWidget.render(#if MC_VER > MC_1_12_2 matrices,#endif mouseX, mouseY, delta); // Render buttons
// Render config title
this.DhDrawCenteredString(matrices, this.font, this.title,
this.DhDrawCenteredString(
#if MC_VER > MC_1_12_2
matrices, this.font,
#endif
this.title,
this.width / 2, 15,
#if MC_VER < MC_1_21_6
0xFFFFFF // RGB white
@@ -726,7 +801,11 @@ public class ClassicConfigGUI
// render DH version
this.DhDrawString(matrices, this.font, TextOrLiteral(ModInfo.VERSION), 2, this.height - 10,
this.DhDrawString(
#if MC_VER > MC_1_12_2
matrices, this.font,
#endif
TextOrLiteral(ModInfo.VERSION), 2, this.height - 10,
#if MC_VER < MC_1_21_6
0xAAAAAA // RGB white
#else
@@ -736,7 +815,11 @@ public class ClassicConfigGUI
// If the update is pending, display this message to inform the user that it will apply when the game restarts
if (SelfUpdater.deleteOldJarOnJvmShutdown)
{
this.DhDrawString(matrices, this.font, Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42,
this.DhDrawString(
#if MC_VER > MC_1_12_2
matrices, this.font,
#endif
Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42,
#if MC_VER < MC_1_21_6
0xFFFFFF // RGB white
#else
@@ -745,20 +828,28 @@ public class ClassicConfigGUI
}
this.renderTooltip(matrices, mouseX, mouseY, delta);
this.renderTooltip(
#if MC_VER > MC_1_12_2
matrices,
#endif
mouseX, mouseY, delta);
#if MC_VER < MC_1_20_2
#if MC_VER <= MC_1_12_2
super.drawScreen(mouseX, mouseY, delta);
#elif MC_VER < MC_1_20_2
super.render(matrices, mouseX, mouseY, delta);
#endif
}
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
private void renderTooltip(int mouseX, int mouseY, float delta)
#elif MC_VER < MC_1_20_1
private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta)
#else
private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta)
#endif
{
AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
#if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
if (hoveredWidget == null)
{
return;
@@ -790,23 +881,83 @@ public class ClassicConfigGUI
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
if (configGuiInfo.errorMessage != null)
{
this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY);
this.DhRenderTooltip(
#if MC_VER > MC_1_12_2
matrices, this.font,
#endif
configGuiInfo.errorMessage, mouseX, mouseY);
}
// display the tooltip if present
else if (LANG_WRAPPER.langExists(key))
{
List<Component> list = new ArrayList<>();
List<#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> list = new ArrayList<>();
String lang = LANG_WRAPPER.getLang(key);
for (String langLine : lang.split("\n"))
{
list.add(TextOrTranslatable(langLine));
}
this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY);
this.DhRenderComponentTooltip(
#if MC_VER > MC_1_12_2
matrices, this.font,
#endif
list, mouseX, mouseY);
}
}
//==========//
// input //
//==========//
#if MC_VER <= MC_1_12_2
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws java.io.IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children)
{
if (entry.button instanceof GuiButton btn && btn.visible)
{
if (mouseX >= btn.x && mouseX < btn.x + btn.width
&& mouseY >= btn.y && mouseY < btn.y + btn.height)
{
btn.mousePressed(this.mc, mouseX, mouseY);
OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(btn);
if (handler != null) handler.pressed(btn);
}
}
else if (entry.button instanceof GuiTextField field && field.getVisible())
{
field.mouseClicked(mouseX, mouseY, mouseButton);
}
if (entry.resetButton instanceof GuiButton reset && reset.visible)
{
if (mouseX >= reset.x && mouseX < reset.x + reset.width
&& mouseY >= reset.y && mouseY < reset.y + reset.height)
{
reset.mousePressed(this.mc, mouseX, mouseY);
OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(reset);
if (handler != null) handler.pressed(reset);
}
}
}
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws java.io.IOException
{
super.keyTyped(typedChar, keyCode);
for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children)
{
if (entry.button instanceof GuiTextField field)
{
field.textboxKeyTyped(typedChar, keyCode);
}
}
}
#endif
//==========//
// shutdown //
@@ -814,11 +965,16 @@ public class ClassicConfigGUI
/** When you close it, it goes to the previous screen and saves */
@Override
#if MC_VER <= MC_1_12_2
public void onGuiClosed()
#else
public void onClose()
#endif
{
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
#if MC_VER > MC_1_12_2
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
#endif
CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
}
@@ -831,12 +987,17 @@ public class ClassicConfigGUI
// helper classes //
//================//
public static class ConfigListWidget extends ContainerObjectSelectionList<DhButtonEntry>
public static class ConfigListWidget #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList<DhButtonEntry> #endif
{
#if MC_VER <= MC_1_12_2
private List<DhButtonEntry> children = new ArrayList<>();
#else
Font textRenderer;
#endif
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
{
#if MC_VER > MC_1_12_2
#if MC_VER < MC_1_20_4
super(minecraftClient, canvasWidth, canvasHeight, topMargin, canvasHeight - botMargin, itemSpacing);
#else
@@ -845,72 +1006,122 @@ public class ClassicConfigGUI
this.centerListVertically = false;
this.textRenderer = minecraftClient.font;
#endif
}
#if MC_VER <= MC_1_12_2
public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, GuiButton resetButton, GuiButton indexButton, ITextComponent text)
#else
public void addButton(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, AbstractWidget resetButton, AbstractWidget indexButton, Component text)
{ this.addEntry(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); }
#endif
{ this.#if MC_VER <= MC_1_12_2 children.add #else addEntry #endif(new DhButtonEntry(gui, dhConfigType, button, text, resetButton, indexButton)); }
#if MC_VER > MC_1_12_2
@Override
public int getRowWidth() { return 10_000; }
#endif
public AbstractWidget getHoveredButton(double mouseX, double mouseY)
public #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif getHoveredButton(double mouseX, double mouseY)
{
for (DhButtonEntry buttonEntry : this.children())
for (DhButtonEntry buttonEntry : this.children#if MC_VER > MC_1_12_2() #endif)
{
AbstractWidget button = buttonEntry.button;
if (button != null
&& button.visible)
#if MC_VER <= MC_1_12_2
Gui gui = buttonEntry.button;
if (gui == null) continue;
double minX, minY, maxX, maxY;
if (gui instanceof GuiButton button)
{
#if MC_VER < MC_1_19_4
double minX = button.x;
double minY = button.y;
#else
double minX = button.getX();
double minY = button.getY();
#endif
double maxX = minX + button.getWidth();
double maxY = minY + button.getHeight();
if (mouseX >= minX && mouseX < maxX
&& mouseY >= minY && mouseY < maxY)
{
return button;
}
if (!button.visible) continue;
minX = button.x;
minY = button.y;
maxX = minX + button.width;
maxY = minY + button.height;
}
else if (gui instanceof GuiTextField field)
{
if (!field.getVisible()) continue;
minX = field.x;
minY = field.y;
maxX = minX + field.width;
maxY = minY + field.height;
}
else
{
continue;
}
if (mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY)
{
return gui;
}
#else
AbstractWidget button = (AbstractWidget) buttonEntry.button;
if (button == null || !button.visible) continue;
#if MC_VER < MC_1_19_4
double minX = button.x;
double minY = button.y;
#else
double minX = button.getX();
double minY = button.getY();
#endif
double maxX = minX + button.getWidth();
double maxY = minY + button.getHeight();
if (mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY)
{
return button;
}
#endif
}
return null;
}
#if MC_VER <= MC_1_12_2
public void render(int mouseX, int mouseY, float delta) {
int y = 40;
for (DhButtonEntry buttonEntry : this.children)
{
buttonEntry.render(y, 0, mouseX, mouseY, delta);
y += 25;
}
}
#endif
}
public static class DhButtonEntry extends ContainerObjectSelectionList.Entry<DhButtonEntry>
public static class DhButtonEntry #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList.Entry<DhButtonEntry> #endif
{
private static final Font textRenderer = Minecraft.getInstance().font;
private static final #if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer = Minecraft. #if MC_VER <= MC_1_12_2 getMinecraft().fontRenderer; #else .getInstance().font; #endif
private final AbstractWidget button;
private final #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif button;
private final DhConfigScreen gui;
private final AbstractConfigBase dhConfigType;
private final AbstractWidget resetButton;
private final AbstractWidget indexButton;
private final Component text;
private final List<AbstractWidget> children = new ArrayList<>();
private final #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif resetButton;
private final #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif indexButton;
private final #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif text;
private final List<#if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif> children = new ArrayList<>();
@NotNull
private final EConfigCommentTextPosition textPosition;
public static final Map<AbstractWidget, Component> TEXT_BY_WIDGET = new HashMap<>();
public static final Map<AbstractWidget, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> TEXT_BY_WIDGET = new HashMap<>();
public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
public DhButtonEntry(
DhConfigScreen gui, AbstractConfigBase dhConfigType,
AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton)
#if MC_VER <= MC_1_12_2
public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, Gui button, ITextComponent text, GuiButton resetButton, GuiButton indexButton)
#else
public DhButtonEntry(DhConfigScreen gui, AbstractConfigBase dhConfigType, AbstractWidget button, Component text, AbstractWidget resetButton, AbstractWidget indexButton)
#endif
{
TEXT_BY_WIDGET.put(button, text);
BUTTON_BY_WIDGET.put(button, this);
@@ -951,13 +1162,16 @@ public class ClassicConfigGUI
}
#if MC_VER <= MC_1_12_2
public void render(int y, int x, int mouseX, int mouseY, float tickDelta)
#elif MC_VER < MC_1_20_1
@Override
#if MC_VER < MC_1_20_1
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
#elif MC_VER < MC_1_21_9
@Override
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
#else
@Override
public void renderContent(GuiGraphics matrices, int mouseX, int mouseY, boolean hovered, float tickDelta)
#endif
{
@@ -976,25 +1190,50 @@ public class ClassicConfigGUI
if (this.button != null)
{
#if MC_VER <= MC_1_12_2
if (this.button instanceof GuiButton guiButton)
{
SetY(guiButton, y);
guiButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
}
if (this.button instanceof GuiTextField guiTextField)
{
SetY(guiTextField, y);
guiTextField.drawTextBox();
}
#else
SetY(this.button, y);
this.button.render(matrices, mouseX, mouseY, tickDelta);
#endif
}
if (this.resetButton != null)
{
SetY(this.resetButton, y);
SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.resetButton, y);
#if MC_VER <= MC_1_12_2
((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
#else
this.resetButton.render(matrices, mouseX, mouseY, tickDelta);
#endif
}
if (this.indexButton != null)
{
SetY(this.indexButton, y);
SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.indexButton, y);
#if MC_VER <= MC_1_12_2
((GuiButton) this.indexButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
#else
this.indexButton.render(matrices, mouseX, mouseY, tickDelta);
#endif
}
if (this.text != null)
{
#if MC_VER <= MC_1_12_2
int translatedLength = textRenderer.getStringWidth(this.text.getFormattedText());
#else
int translatedLength = textRenderer.width(this.text);
#endif
int textXPos;
if (this.textPosition == EConfigCommentTextPosition.RIGHT_JUSTIFIED)
@@ -1027,8 +1266,9 @@ public class ClassicConfigGUI
throw new UnsupportedOperationException("No text position render defined for [" + this.textPosition + "]");
}
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
textRenderer.drawString(this.text.getFormattedText(), textXPos, y + 5,0xFFFFFF);
#elif MC_VER < MC_1_20_1
GuiComponent.drawString(matrices, textRenderer,
this.text,
textXPos, y + 5,
@@ -1053,9 +1293,11 @@ public class ClassicConfigGUI
}
}
#if MC_VER > MC_1_12_2
@Override
public @NotNull List<? extends GuiEventListener> children()
{ return this.children; }
#endif
#if MC_VER >= MC_1_17_1
@Override
@@ -1,5 +1,10 @@
package com.seibel.distanthorizons.common.wrappers.gui;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.text.ITextComponent;
#else
import net.minecraft.client.gui.Font;
#if MC_VER < MC_1_20_1
import com.mojang.blaze3d.vertex.PoseStack;
@@ -9,29 +14,67 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
#endif
import java.util.List;
public class DhScreen extends Screen
public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif
{
protected DhScreen(Component $$0)
#if MC_VER <= MC_1_12_2
protected ITextComponent title;
protected DhScreen(ITextComponent title)
{
super($$0);
this.title = title;
}
#else
protected DhScreen(Component title)
{
super(title);
}
#endif
// addRenderableWidget in 1.17 and over
// addButton in 1.16 and below
protected Button addBtn(Button button)
protected #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif addBtn(#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button)
{
#if MC_VER < MC_1_17_1
#if MC_VER <= MC_1_12_2
this.buttonList.add(button);
return button;
#elif MC_VER < MC_1_17_1
return this.addButton(button);
#else
return this.addRenderableWidget(button);
#endif
}
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
@Override
protected void actionPerformed(GuiButton button)
{
OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(button);
if (handler != null)
{
handler.pressed(button);
}
}
protected void DhDrawCenteredString(ITextComponent text, int x, int y, int color) {
drawCenteredString(fontRenderer, text.getFormattedText(), x, y, color);
}
protected void DhDrawString(ITextComponent text, int x, int y, int color) {
drawString(fontRenderer, text.getFormattedText(), x, y, color);
}
protected void DhRenderComponentTooltip(List<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)
{
drawCenteredString(guiStack, font, text, x, y, color);
@@ -3,14 +3,18 @@ package com.seibel.distanthorizons.common.wrappers.gui;
import com.seibel.distanthorizons.core.config.ConfigHandler;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.coreapi.ModInfo;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiScreen;
#else
import net.minecraft.client.gui.screens.Screen;
#endif
import com.seibel.distanthorizons.core.logging.DhLogger;
public class GetConfigScreen
{
protected static final DhLogger LOGGER = new DhLoggerBuilder().build();
public static Screen getScreen(Screen parent)
public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent)
{
if (ModInfo.IS_DEV_BUILD)
{
@@ -1,11 +1,21 @@
package com.seibel.distanthorizons.common.wrappers.gui;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import java.util.HashMap;
import java.util.Map;
#else
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
#endif
#if MC_VER < MC_1_19_2
#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
#endif
@@ -15,43 +25,58 @@ public class GuiHelper
/**
* Helper static methods for versional compat
*/
public static Button MakeBtn(Component base, int posX, int posZ, int width, int height, Button.OnPress action)
#if MC_VER <= MC_1_12_2
public static final Map<GuiButton, OnPressed> HANDLER_BY_BUTTON = new HashMap<>();
#endif
public static #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif MakeBtn(#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif base, int posX, int posZ, int width, int height,
#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif action)
{
#if MC_VER < MC_1_19_4
#if MC_VER <= MC_1_12_2
GuiButton button = new GuiButton(HANDLER_BY_BUTTON.size(), posX, posZ, width, height, base.getFormattedText());
HANDLER_BY_BUTTON.put(button, action);
return button;
#elif MC_VER < MC_1_19_4
return new Button(posX, posZ, width, height, base, action);
#else
return Button.builder(base, action).bounds(posX, posZ, width, height).build();
#endif
}
public static MutableComponent TextOrLiteral(String text)
public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrLiteral(String text)
{
#if MC_VER < MC_1_19_2
#if MC_VER <= MC_1_12_2
return new TextComponentString(text);
#elif MC_VER < MC_1_19_2
return new TextComponent(text);
#else
return Component.literal(text);
#endif
}
public static MutableComponent TextOrTranslatable(String text)
public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrTranslatable(String text)
{
#if MC_VER < MC_1_19_2
#if MC_VER <= MC_1_12_2
return new TextComponentString(text);
#elif MC_VER < MC_1_19_2
return new TextComponent(text);
#else
return Component.translatable(text);
#endif
}
public static MutableComponent Translatable(String text, Object... args)
public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif Translatable(String text, Object... args)
{
#if MC_VER < MC_1_19_2
#if MC_VER <= MC_1_12_2
return new TextComponentTranslation(text, args);
#elif MC_VER < MC_1_19_2
return new TranslatableComponent(text, args);
#else
return Component.translatable(text, args);
#endif
}
public static void SetX(AbstractWidget w, int x)
public static void SetX(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int x)
{
#if MC_VER < MC_1_19_4
w.x = x;
@@ -60,7 +85,18 @@ public class GuiHelper
#endif
}
public static void SetY(AbstractWidget w, int y)
#if MC_VER <= MC_1_12_2
public static void SetY(GuiTextField w, int y)
{
#if MC_VER < MC_1_19_4
w.y = y;
#else
w.setY(y);
#endif
}
#endif
public static void SetY(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int y)
{
#if MC_VER < MC_1_19_4
w.y = y;
@@ -1,21 +1,32 @@
package com.seibel.distanthorizons.common.wrappers.gui;
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.resources.I18n;
#else
import net.minecraft.client.resources.language.I18n;
#endif
public class LangWrapper implements ILangWrapper
{
public static final LangWrapper INSTANCE = new LangWrapper();
@Override
public boolean langExists(String str)
{
#if MC_VER <= MC_1_12_2
return I18n.hasKey(str);
#else
return I18n.exists(str);
#endif
}
@Override
public String getLang(String str)
{
#if MC_VER <= MC_1_12_2
return I18n.format(str);
#else
return I18n.get(str);
#endif
}
}
@@ -1,14 +1,19 @@
package com.seibel.distanthorizons.common.wrappers.gui;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiScreen;
import org.lwjglx.opengl.Display;
#else
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.screens.Screen;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;
#endif
import com.seibel.distanthorizons.core.config.gui.AbstractScreen;
import net.minecraft.client.Minecraft;
#if MC_VER >= MC_1_20_1
import net.minecraft.client.gui.GuiGraphics;
#endif
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.NotNull;
import java.nio.file.Path;
@@ -16,19 +21,21 @@ import java.util.*;
public class MinecraftScreen
{
public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName)
public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName)
{
return new ConfigScreenRenderer(parent, screen, translationName);
}
private static class ConfigScreenRenderer extends DhScreen
{
private final Screen parent;
private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent;
private ConfigListWidget configListWidget;
private AbstractScreen screen;
#if MC_VER < MC_1_19_2
#if MC_VER <= MC_1_12_2
public static net.minecraft.util.text.TextComponentTranslation translate(String str, Object... args)
{ return new net.minecraft.util.text.TextComponentTranslation(str, args); }
#elif MC_VER < MC_1_19_2
public static net.minecraft.network.chat.TranslatableComponent translate(String str, Object... args)
{ return new net.minecraft.network.chat.TranslatableComponent(str, args); }
#else
@@ -36,10 +43,12 @@ public class MinecraftScreen
{ return net.minecraft.network.chat.Component.translatable(str, args); }
#endif
protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName)
protected ConfigScreenRenderer(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName)
{
super(translate(translationName));
#if MC_VER < MC_1_21_9
#if MC_VER <= MC_1_12_2
screen.minecraftWindow = Display.getWindow();
#elif MC_VER < MC_1_21_9
screen.minecraftWindow = Minecraft.getInstance().getWindow().getWindow();
#else
screen.minecraftWindow = Minecraft.getInstance().getWindow().handle();
@@ -49,18 +58,28 @@ public class MinecraftScreen
}
@Override
#if MC_VER <= MC_1_12_2
public void initGui()
#else
protected void init()
#endif
{
super.init(); // Init Minecraft's screen
super.#if MC_VER <= MC_1_12_2 initGui(); #else init(); #endif // Init Minecraft's screen
#if MC_VER <= MC_1_12_2
this.screen.width = Display.getWidth();
this.screen.height = Display.getHeight();
#else
Window mcWindow = this.minecraft.getWindow();
this.screen.width = mcWindow.getWidth();
this.screen.height = mcWindow.getHeight();
#endif
this.screen.scaledWidth = this.width;
this.screen.scaledHeight = this.height;
this.screen.init(); // Init our own config screen
this.configListWidget = new ConfigListWidget(this.minecraft, this.width, this.height, 0, 0, 25); // Select the area to tint
this.configListWidget = new ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width, this.height, 0, 0, 25); // Select the area to tint
#if MC_VER > MC_1_12_2
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
if (this.minecraft != null && this.minecraft.level != null) // Check if in game
{
@@ -69,16 +88,21 @@ public class MinecraftScreen
#endif
this.addWidget(this.configListWidget); // Add the tint to the things to be rendered
#endif
}
@Override
#if MC_VER < MC_1_20_1
#if MC_VER <= MC_1_12_2
public void drawScreen(int mouseX, int mouseY, float delta)
#elif MC_VER < MC_1_20_1
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
#else
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
#endif
{
#if MC_VER < MC_1_20_2
#if MC_VER <= MC_1_12_2
this.drawDefaultBackground();
#elif MC_VER < MC_1_20_2
this.renderBackground(matrices); // Render background
#elif MC_VER < MC_1_21_6
this.renderBackground(matrices, mouseX, mouseY, delta); // Render background
@@ -86,57 +110,89 @@ public class MinecraftScreen
// background blur is already being rendered, rendering again causes the game to crash
#endif
#if MC_VER > MC_1_12_2
this.configListWidget.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
#endif
this.screen.mouseX = mouseX;
this.screen.mouseY = mouseY;
this.screen.render(delta); // Render everything on the main screen
#if MC_VER <= MC_1_12_2
super.drawScreen(mouseX, mouseY, delta);
#else
super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint)
#endif
}
@Override
#if MC_VER <= MC_1_21_10
@Override
#if MC_VER <= MC_1_12_2
public void setWorldAndResolution(Minecraft mc, int width, int height)
#else
public void resize(Minecraft mc, int width, int height)
#endif
#else
@Override
public void resize(int width, int height)
#endif
{
// Resize Minecraft's screen
#if MC_VER <= MC_1_21_10
#if MC_VER <= MC_1_12_2
super.setWorldAndResolution(mc, width, height);
#elif MC_VER <= MC_1_21_10
super.resize(mc, width, height);
#else
super.resize(width, height);
#endif
#if MC_VER <= MC_1_12_2
this.screen.width = Display.getWidth();
this.screen.height = Display.getHeight();
#else
Window mcWindow = this.minecraft.getWindow();
this.screen.width = mcWindow.getWidth();
this.screen.height = mcWindow.getHeight();
#endif
this.screen.scaledWidth = this.width;
this.screen.scaledHeight = this.height;
this.screen.onResize(); // Resize our screen
}
@Override
#if MC_VER <= MC_1_12_2
public void updateScreen()
#else
public void tick()
#endif
{
super.tick(); // Tick Minecraft's screen
super.#if MC_VER <= MC_1_12_2 updateScreen(); #else tick(); #endif // Tick Minecraft's screen
this.screen.tick(); // Tick our screen
if (this.screen.close) // If we decide to close the screen, then actually close the screen
{
#if MC_VER <= MC_1_12_2
this.onGuiClosed();
#else
this.onClose();
#endif
}
}
@Override
#if MC_VER <= MC_1_12_2
public void onGuiClosed()
#else
public void onClose()
#endif
{
this.screen.onClose(); // Close our screen
#if MC_VER <= MC_1_12_2
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
#else
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen
#endif
}
#if MC_VER > MC_1_12_2
@Override
public void onFilesDrop(@NotNull List<Path> files)
{ this.screen.onFilesDrop(files); }
@@ -145,19 +201,21 @@ public class MinecraftScreen
@Override
public boolean shouldCloseOnEsc()
{ return this.screen.shouldCloseOnEsc; }
#endif
}
public static class ConfigListWidget extends ContainerObjectSelectionList
public static class ConfigListWidget #if MC_VER > MC_1_12_2 extends ContainerObjectSelectionList #endif
{
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
{
#if MC_VER > MC_1_12_2
#if MC_VER < MC_1_20_4
super(minecraftClient, canvasWidth, canvasHeight, topMargin, canvasHeight - botMargin, itemSpacing);
#else
super(minecraftClient, canvasWidth, canvasHeight - (topMargin + botMargin), topMargin, itemSpacing);
#endif
this.centerListVertically = false;
#endif
}
}
@@ -0,0 +1,8 @@
package com.seibel.distanthorizons.common.wrappers.gui;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiButton;
public interface OnPressed {
void pressed(GuiButton button);
}
#endif
@@ -18,14 +18,20 @@
*/
package com.seibel.distanthorizons.common.wrappers.gui;
#if MC_VER > MC_1_12_2
import net.minecraft.network.chat.Component;
#endif
#if MC_VER >= MC_1_17_1
import net.minecraft.client.gui.components.Button;
#endif
#if MC_VER < MC_1_17_1
#if MC_VER <= MC_1_12_2
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
#elif MC_VER < MC_1_17_1
import net.minecraft.client.gui.components.ImageButton;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
@@ -50,7 +56,9 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderPipelines;
#endif
#if MC_VER <= MC_1_21_10
#if MC_VER <= MC_1_12_2
import net.minecraft.util.ResourceLocation;
#elif MC_VER <= MC_1_21_10
import net.minecraft.resources.ResourceLocation;
#else
import net.minecraft.resources.Identifier;
@@ -63,14 +71,14 @@ import net.minecraft.resources.Identifier;
* @version 2023-10-03
*/
#if MC_VER < MC_1_20_2
public class TexturedButtonWidget extends ImageButton
public class TexturedButtonWidget extends #if MC_VER <= MC_1_12_2 GuiButton #else ImageButton #endif
#else
public class TexturedButtonWidget extends Button
#endif
{
public final boolean renderBackground;
#if MC_VER >= MC_1_20_2
#if MC_VER >= MC_1_20_2 || MC_VER <= MC_1_12_2
private final int u;
private final int v;
private final int hoveredVOffset;
@@ -87,27 +95,40 @@ public class TexturedButtonWidget extends Button
public TexturedButtonWidget(
int x, int y, int width, int height, int u, int v, int hoveredVOffset,
#if MC_VER <= MC_1_12_2 int id ,#endif int x, int y, int width, int height, int u, int v, int hoveredVOffset,
#if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation,
#else Identifier textureResourceLocation,
#endif
int textureWidth, int textureHeight, OnPress pressAction, Component text)
int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text)
{
this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true);
this(
#if MC_VER <= MC_1_12_2
id,
#endif
x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight,
#if MC_VER > MC_1_12_2
pressAction,
#endif
text, true
);
}
public TexturedButtonWidget(
int x, int y, int width, int height, int u, int v, int hoveredVOffset,
#if MC_VER <= MC_1_12_2 int id ,#endif int x, int y, int width, int height, int u, int v, int hoveredVOffset,
#if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation,
#else Identifier textureResourceLocation,
#endif
int textureWidth, int textureHeight, OnPress pressAction, Component text,
boolean renderBackground)
#endif
int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text, boolean renderBackground)
{
#if MC_VER < MC_1_20_2
#if MC_VER < MC_1_20_2 && MC_VER > MC_1_12_2
super(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text);
#else
#if MC_VER <= MC_1_12_2
super(id, x, y, width, height, text);
#else
// We don't pass in the text option since it will render (we normally pass it in for narration)
super(x, y, width, height, Component.empty(), pressAction, DEFAULT_NARRATION);
#endif
this.u = u;
this.v = v;
@@ -122,7 +143,27 @@ public class TexturedButtonWidget extends Button
this.renderBackground = renderBackground;
}
#if MC_VER < MC_1_20_2
#if MC_VER <= MC_1_12_2
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
//Render vanilla background
mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int i = this.getHoverState(this.hovered);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
//Render DH texture
mc.getTextureManager().bindTexture(textureResourceLocation);
drawModalRectWithCustomSizedTexture(this.x, this.y, this.u, (hoveredVOffset * (i - 1)), this.width, this.height, this.textureWidth, this.textureHeight);
}
}
#elif MC_VER < MC_1_20_2
#if MC_VER < MC_1_19_4
@Override
public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta)
@@ -1,10 +1,17 @@
package com.seibel.distanthorizons.common.wrappers.gui.config;
import com.seibel.distanthorizons.common.wrappers.gui.OnPressed;
import com.seibel.distanthorizons.core.config.gui.IConfigGuiInfo;
import com.seibel.distanthorizons.core.config.types.AbstractConfigBase;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.util.text.ITextComponent;
#else
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
#endif
import org.jetbrains.annotations.Nullable;
import java.util.AbstractMap;
@@ -23,11 +30,12 @@ public class ConfigGuiInfo implements IConfigGuiInfo
* Used to display validation errors.
* Null if no error is present.
*/
@Nullable
public Component errorMessage;
public #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif errorMessage;
public BiFunction<EditBox, Button, Predicate<String>> tooltipFunction;
public BiFunction<#if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif,#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif, Predicate<String>> tooltipFunction;
/** determines which options the button will show */
public AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>> buttonOptionMap;
public AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function<Object, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif>> buttonOptionMap;
}
@@ -1,5 +1,5 @@
package com.seibel.distanthorizons.common.wrappers.gui.updater;
#if MC_VER > MC_1_12_2
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -282,4 +282,5 @@ public class ChangelogScreen extends DhScreen
}
}
}
#endif
@@ -1,5 +1,5 @@
package com.seibel.distanthorizons.common.wrappers.gui.updater;
#if MC_VER > MC_1_12_2
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
@@ -213,4 +213,5 @@ public class UpdateModScreen extends DhScreen
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Go to the parent screen
}
}
}
#endif
@@ -3,7 +3,11 @@ package com.seibel.distanthorizons.common.wrappers.level;
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.multiplayer.WorldClient;
#else
import net.minecraft.client.multiplayer.ClientLevel;
#endif
import org.jetbrains.annotations.Nullable;
public class KeyedClientLevelManager implements IKeyedClientLevelManager
@@ -38,7 +42,7 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
@Override
public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String serverKey, String levelKey)
{
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper((ClientLevel) clientLevel.getWrappedMcObject(), serverKey, levelKey);
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif clientLevel.getWrappedMcObject(), serverKey, levelKey);
this.serverKeyedLevel = keyedLevel;
this.enabled = true;
return keyedLevel;
@@ -2,7 +2,11 @@ package com.seibel.distanthorizons.common.wrappers.level;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.multiplayer.WorldClient;
#else
import net.minecraft.client.multiplayer.ClientLevel;
#endif
public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements IServerKeyedClientLevel
{
@@ -18,7 +22,7 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements
// constructor //
//=============//
public ServerKeyedClientLevelWrapper(ClientLevel level, String serverKey, String serverLevelKey)
public ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, String serverKey, String serverLevelKey)
{
super(level);
this.serverKey = serverKey;
@@ -21,7 +21,6 @@ package com.seibel.distanthorizons.common.wrappers.minecraft;
import java.io.File;
import com.mojang.blaze3d.platform.Window;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
@@ -35,19 +34,30 @@ import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.core.logging.DhLogger;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.crash.CrashReport;
import net.minecraft.profiler.Profiler;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.text.TextComponentString;
#else
import net.minecraft.CrashReport;
import net.minecraft.client.CloudStatus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.ChunkPos;
import com.mojang.blaze3d.platform.Window;
#endif
import org.jetbrains.annotations.Nullable;
#if MC_VER < MC_1_19_2
#if MC_VER < MC_1_19_2 && MC_VER > MC_1_12_2
import net.minecraft.network.chat.TextComponent;
#endif
@@ -56,7 +66,7 @@ import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.profiling.Profiler;
#endif
#if MC_VER <= MC_1_21_10
#if MC_VER <= MC_1_21_10 && MC_VER > MC_1_12_2
import net.minecraft.client.GraphicsStatus;
#else
#endif
@@ -69,7 +79,7 @@ import net.minecraft.client.GraphicsStatus;
public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final Minecraft MINECRAFT = Minecraft.getInstance();
private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper();
@@ -84,17 +94,17 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
//region
@Override
public boolean hasSinglePlayerServer() { return MINECRAFT.hasSingleplayerServer(); }
public boolean hasSinglePlayerServer() { return MINECRAFT.#if MC_VER <= MC_1_12_2 isSingleplayer() #else hasSingleplayerServer() #endif; }
@Override
public boolean clientConnectedToDedicatedServer()
{
return MINECRAFT.getCurrentServer() != null
return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif != null
&& !this.hasSinglePlayerServer();
}
@Override
public boolean connectedToReplay()
{
return MINECRAFT.getCurrentServer() == null
return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif == null
&& !this.hasSinglePlayerServer() ;
}
@@ -107,8 +117,8 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
}
else
{
ServerData server = MINECRAFT.getCurrentServer();
return (server != null) ? server.name : "NULL";
ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif;
return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverName #else name #endif : "NULL";
}
}
@Override
@@ -120,15 +130,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
}
else
{
ServerData server = MINECRAFT.getCurrentServer();
return (server != null) ? server.ip : "NA";
ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif;
return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverIP #else ip #endif : "NA";
}
}
@Override
public String getCurrentServerVersion()
{
ServerData server = MINECRAFT.getCurrentServer();
return (server != null) ? server.version.getString() : "UNKOWN";
ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif;
return (server != null) ? server.#if MC_VER <= MC_1_12_2 gameVersion #else version.getString() #endif : "UNKOWN";
}
//endregion
@@ -140,7 +150,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
//=================//
//region
public LocalPlayer getPlayer() { return MINECRAFT.player; }
public #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif getPlayer() { return MINECRAFT.player; }
@Override
public boolean playerExists() { return MINECRAFT.player != null; }
@@ -148,26 +158,28 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
@Override
public DhBlockPos getPlayerBlockPos()
{
LocalPlayer player = this.getPlayer();
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
if (player == null)
{
return new DhBlockPos(0, 0, 0);
}
BlockPos playerPos = player.blockPosition();
BlockPos playerPos = player.#if MC_VER <= MC_1_12_2 getPosition() #else blockPosition() #endif;
return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ());
}
@Override
public DhChunkPos getPlayerChunkPos()
{
LocalPlayer player = this.getPlayer();
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
if (player == null)
{
return new DhChunkPos(0, 0);
}
#if MC_VER < MC_1_17_1
#if MC_VER <= MC_1_12_2
ChunkPos playerPos = new ChunkPos(player.getPosition());
#elif MC_VER < MC_1_17_1
ChunkPos playerPos = new ChunkPos(player.blockPosition());
#else
ChunkPos playerPos = player.chunkPosition();
@@ -192,7 +204,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
@Nullable
public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager)
{
ClientLevel level = MINECRAFT.level;
#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level = MINECRAFT.#if MC_VER <= MC_1_12_2 world #else level #endif;
if (level == null)
{
return null;
@@ -213,13 +225,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
@Override
public void sendChatMessage(String string)
{
LocalPlayer player = this.getPlayer();
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
if (player == null)
{
return;
}
#if MC_VER < MC_1_19_2
#if MC_VER <= MC_1_12_2
player.sendMessage(new TextComponentString(string));
#elif MC_VER < MC_1_19_2
player.sendMessage(new TextComponent(string), getPlayer().getUUID());
#elif MC_VER < MC_1_21_9
player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/false);
@@ -235,13 +249,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
@Override
public void sendOverlayMessage(String string)
{
LocalPlayer player = this.getPlayer();
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
if (player == null)
{
return;
}
#if MC_VER < MC_1_19_2
#if MC_VER <= MC_1_12_2
MINECRAFT.ingameGUI.setOverlayMessage(string, /*animateColor*/false);
#elif MC_VER < MC_1_19_2
player.displayClientMessage(new TextComponent(string), /*isOverlay*/true);
#else
player.displayClientMessage(net.minecraft.network.chat.Component.translatable(string), /*isOverlay*/true);
@@ -261,7 +277,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
{
LOGGER.info("Disabling vanilla clouds... This is done to prevent vanilla clouds from rendering on top of Distant Horizons LODs.");
#if MC_VER <= MC_1_18_2
#if MC_VER <= MC_1_12_2
MINECRAFT.gameSettings.clouds = 0;
#elif MC_VER <= MC_1_18_2
MINECRAFT.options.renderClouds = CloudStatus.OFF;
#else
MINECRAFT.options.cloudStatus().set(CloudStatus.OFF);
@@ -282,8 +300,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
public void disableFabulousTransparency()
{
String reasoning = "This is done to fix vanilla chunks (specifically water blocks) not fading into Distant Horizons LODs when DH's 'Vanilla Fade' option is enabled.";
#if MC_VER <= MC_1_18_2
#if MC_VER <= MC_1_12_2
// fabulous graphics was added in MC 1.16
#elif MC_VER <= MC_1_18_2
LOGGER.info("Disabling fabulous graphics... "+reasoning);
GraphicsStatus oldGraphicsStatus = MINECRAFT.options.graphicsMode;
@@ -319,6 +338,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
* no override and not included in {@link IMinecraftClientWrapper}
* since this would only be used in common/client, not core.
*/
#if MC_VER > MC_1_12_2
public
#if MC_VER < MC_1_21_9 long
#else Window
@@ -332,12 +352,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
return MINECRAFT.getWindow();
#endif
}
#endif
@Override
public IProfilerWrapper getProfiler()
{
ProfilerFiller profiler;
#if MC_VER < MC_1_21_3
#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler;
#if MC_VER <= MC_1_12_2
profiler = MINECRAFT.profiler;
#elif MC_VER < MC_1_21_3
profiler = MINECRAFT.getProfiler();
#else
profiler = Profiler.get();
@@ -360,7 +383,9 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
{
LOGGER.fatal(ModInfo.READABLE_NAME + " had the following error: [" + errorMessage + "]. Crashing Minecraft...", exception);
CrashReport report = new CrashReport(errorMessage, exception);
#if MC_VER < MC_1_20_4
#if MC_VER <= MC_1_12_2
MINECRAFT.crashed(report);
#elif MC_VER < MC_1_20_4
Minecraft.crash(report);
#else
MINECRAFT.delayCrash(report);
@@ -368,7 +393,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
}
@Override
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.#if MC_VER <= MC_1_12_2 addScheduledTask #else execute #endif(runnable); }
//endregion
@@ -380,7 +405,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
//region
@Override
public Object getOptionsObject() { return MINECRAFT.options; }
public Object getOptionsObject() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameSettings #else options #endif; }
//endregion
@@ -395,19 +420,23 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
public boolean isDedicatedServer() { return false; }
@Override
public File getInstallationDirectory() { return MINECRAFT.gameDirectory; }
public File getInstallationDirectory() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameDir #else gameDirectory #endif; }
@Override
public int getPlayerCount()
{
// can be null if the server hasn't finished booting up yet
if (MINECRAFT.getSingleplayerServer() == null)
if (MINECRAFT.#if MC_VER <= MC_1_12_2 getIntegratedServer() #else getSingleplayerServer() #endif == null)
{
return 1;
}
else
{
#if MC_VER <= MC_1_12_2
return MINECRAFT.getIntegratedServer().getCurrentPlayerCount();
#else
return MINECRAFT.getSingleplayerServer().getPlayerCount();
#endif
}
}
@@ -19,7 +19,9 @@
package com.seibel.distanthorizons.common.wrappers.minecraft;
#if MC_VER < MC_1_21_5
#if MC_VER <= MC_1_12_2
import net.minecraft.client.renderer.GlStateManager;
#elif MC_VER < MC_1_21_5
import com.mojang.blaze3d.platform.GlStateManager;
#else
import com.mojang.blaze3d.opengl.GlStateManager;
@@ -72,14 +74,18 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void enableScissorTest()
{
GL32.glEnable(GL32.GL_SCISSOR_TEST);
#if MC_VER > MC_1_12_2
GlStateManager._enableScissorTest();
#endif
}
/** @see GL32#GL_SCISSOR_TEST */
@Override
public void disableScissorTest()
{
GL32.glDisable(GL32.GL_SCISSOR_TEST);
GlStateManager._disableScissorTest();
#if MC_VER > MC_1_12_2
GlStateManager._disableScissorTest();
#endif
}
@@ -98,14 +104,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void enableDepthTest()
{
GL32.glEnable(GL32.GL_DEPTH_TEST);
#if MC_VER <= MC_1_12_2
GlStateManager.enableDepth();
#else
GlStateManager._enableDepthTest();
#endif
}
/** @see GL32#GL_DEPTH_TEST */
@Override
public void disableDepthTest()
{
GL32.glDisable(GL32.GL_DEPTH_TEST);
#if MC_VER <= MC_1_12_2
GlStateManager.disableDepth();
#else
GlStateManager._disableDepthTest();
#endif
}
/** @see GL32#glDepthFunc(int) */
@@ -113,7 +127,11 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void glDepthFunc(int func)
{
GL32.glDepthFunc(func);
#if MC_VER <= MC_1_12_2
GlStateManager.depthFunc(func);
#else
GlStateManager._depthFunc(func);
#endif
}
/** @see GL32#glDepthMask(boolean) */
@@ -121,14 +139,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void enableDepthMask()
{
GL32.glDepthMask(true);
GlStateManager._depthMask(true);
#if MC_VER <= MC_1_12_2
GlStateManager.depthMask(true);
#else
GlStateManager._depthMask(true);
#endif
}
/** @see GL32#glDepthMask(boolean) */
@Override
public void disableDepthMask()
{
GL32.glDepthMask(false);
#if MC_VER <= MC_1_12_2
GlStateManager.depthMask(false);
#else
GlStateManager._depthMask(false);
#endif
}
@@ -139,14 +165,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void enableBlend()
{
GL32.glEnable(GL32.GL_BLEND);
#if MC_VER <= MC_1_12_2
GlStateManager.enableBlend();
#else
GlStateManager._enableBlend();
#endif
}
/** @see GL32#GL_BLEND */
@Override
public void disableBlend()
{
GL32.glDisable(GL32.GL_BLEND);
#if MC_VER <= MC_1_12_2
GlStateManager.disableBlend();
#else
GlStateManager._disableBlend();
#endif
}
/** @see GL32#glBlendFunc */
@@ -154,8 +188,9 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void glBlendFunc(int sfactor, int dfactor)
{
GL32.glBlendFunc(sfactor, dfactor);
#if MC_VER < MC_1_21_5
#if MC_VER <= MC_1_12_2
GlStateManager.blendFunc(sfactor, dfactor);
#elif MC_VER < MC_1_21_5
GlStateManager._blendFunc(sfactor, dfactor);
#endif
}
@@ -164,7 +199,11 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void glBlendFuncSeparate(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha)
{
GL32.glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
GlStateManager._blendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
#if MC_VER <= MC_1_12_2
GlStateManager.tryBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
#else
GlStateManager._blendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
#endif
}
@@ -175,7 +214,9 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void glBindFramebuffer(int target, int framebuffer)
{
GL32.glBindFramebuffer(target, framebuffer);
GlStateManager._glBindFramebuffer(target, framebuffer);
#if MC_VER > MC_1_12_2
GlStateManager._glBindFramebuffer(target, framebuffer);
#endif
}
@@ -222,14 +263,22 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void enableFaceCulling()
{
GL32.glEnable(GL32.GL_CULL_FACE);
GlStateManager._enableCull();
#if MC_VER <= MC_1_12_2
GlStateManager.enableCull();
#else
GlStateManager._enableCull();
#endif
}
/** @see GL32#GL_CULL_FACE */
@Override
public void disableFaceCulling()
{
GL32.glDisable(GL32.GL_CULL_FACE);
GlStateManager._disableCull();
#if MC_VER <= MC_1_12_2
GlStateManager.disableCull();
#else
GlStateManager._disableCull();
#endif
}
@@ -237,17 +286,35 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
/** @see GL32#glGenTextures() */
@Override
public int glGenTextures() { return GlStateManager._genTexture(); }
public int glGenTextures()
{
#if MC_VER <= MC_1_12_2
return GlStateManager.generateTexture();
#else
return GlStateManager._genTexture();
#endif
}
/** @see GL32#glDeleteTextures(int) */
@Override
public void glDeleteTextures(int texture) { GlStateManager._deleteTexture(texture); }
public void glDeleteTextures(int texture)
{
#if MC_VER <= MC_1_12_2
GlStateManager.deleteTexture(texture);
#else
GlStateManager._deleteTexture(texture);
#endif
}
/** @see GL32#glActiveTexture(int) */
@Override
public void glActiveTexture(int textureId)
{
{
GL32.glActiveTexture(textureId);
#if MC_VER <= MC_1_12_2
GlStateManager.setActiveTexture(textureId);
#else
GlStateManager._activeTexture(textureId);
#endif
}
@Override
public int getActiveTexture() { return GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D); }
@@ -260,7 +327,11 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper
public void glBindTexture(int texture)
{
GL32.glBindTexture(GL32.GL_TEXTURE_2D, texture);
#if MC_VER <= MC_1_12_2
GlStateManager.bindTexture(texture);
#else
GlStateManager._bindTexture(texture);
#endif
}
@@ -23,8 +23,6 @@ import java.awt.Color;
import java.lang.invoke.MethodHandles;
import java.util.concurrent.ConcurrentHashMap;
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.platform.NativeImage;
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
@@ -59,6 +57,14 @@ import com.seibel.distanthorizons.core.util.math.Vec3d;
import com.seibel.distanthorizons.core.util.math.Vec3f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.MobEffects;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fluids.IFluidBlock;
#else
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
@@ -66,11 +72,17 @@ import net.minecraft.core.Direction;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.phys.Vec3;
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.platform.NativeImage;
#endif
import com.seibel.distanthorizons.core.logging.DhLogger;
import org.jetbrains.annotations.NotNull;
import org.joml.Vector4f;
#if MC_VER < MC_1_17_1
#if MC_VER <= MC_1_12_2
import org.lwjgl.opengl.GL15;
#elif MC_VER < MC_1_17_1
import net.minecraft.tags.FluidTags;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.material.FluidState;
@@ -98,7 +110,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final Minecraft MC = Minecraft.getInstance();
private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
/**
* In the case of immersive portals multiple levels may be active at once, causing conflicting lightmaps. <br>
@@ -129,7 +141,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public Vec3f getLookAtVector()
{
#if MC_VER <= MC_1_21_10
#if MC_VER <= MC_1_12_2
net.minecraft.util.math.Vec3d lookVector = (MC.getRenderViewEntity().getLook(MC.getRenderPartialTicks()));
return new Vec3f((float) lookVector.x, (float) lookVector.y, (float) lookVector.z);
#elif MC_VER <= MC_1_21_10
Camera camera = MC.gameRenderer.getMainCamera();
return new Vec3f(camera.getLookVector().x(), camera.getLookVector().y(), camera.getLookVector().z());
#else
@@ -149,37 +164,48 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
{
return false;
}
else if (MC.player.getActiveEffectsMap() == null)
else if (MC.player.#if MC_VER <= MC_1_12_2 getActivePotionMap() #else getActiveEffectsMap() #endif == null)
{
return false;
}
else
{
#if MC_VER <= MC_1_12_2
return MC.player.getActivePotionEffect(MobEffects.BLINDNESS) != null;
#else
return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null
#if MC_VER >= MC_1_19_2
|| MC.player.getActiveEffectsMap().get(MobEffects.DARKNESS) != null // Deep dark effect
#endif
;
#endif
}
}
@Override
public Vec3d getCameraExactPosition()
{
#if MC_VER <= MC_1_12_2
RenderManager rm = MC.getRenderManager();
return new Vec3d(rm.viewerPosX, rm.viewerPosY, rm.viewerPosZ);
#else
Camera camera = MC.gameRenderer.getMainCamera();
#if MC_VER <= MC_1_21_10
Vec3 projectedView = camera.getPosition();
#else
Vec3 projectedView = camera.position();
#endif
return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
#endif
}
@Override
public float getPartialTickTime()
{
#if MC_VER < MC_1_21_1
#if MC_VER <= MC_1_12_2
return MC.getRenderPartialTicks();
#elif MC_VER < MC_1_21_1
return MC.getFrameTime();
#elif MC_VER < MC_1_21_3
return MC.getTimer().getRealtimeDeltaTicks();
@@ -272,11 +298,19 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public Color getSkyColor()
{
#if MC_VER <= MC_1_12_2
if (MC.world.provider.hasSkyLight())
#else
if (MC.level.dimensionType().hasSkyLight())
#endif
{
#if MC_VER < MC_1_17_1
float frameTime = this.getPartialTickTime();
#if MC_VER <= MC_1_12_2
net.minecraft.util.math.Vec3d colorValues = MC.world.getSkyColor(MC.getRenderViewEntity(), frameTime);
#else
Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), frameTime);
#endif
return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
#elif MC_VER < MC_1_21_3
float frameTime = this.getPartialTickTime();
@@ -298,13 +332,22 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
}
@Override
public double getFov(float partialTicks) { return MC.gameRenderer.getFov(MC.gameRenderer.getMainCamera(), partialTicks, true); }
public double getFov(float partialTicks)
{
#if MC_VER <= MC_1_12_2
return MC.entityRenderer.getFOVModifier(partialTicks, true);
#else
return MC.gameRenderer.getFov(MC.gameRenderer.getMainCamera(), partialTicks, true);
#endif
}
/** Measured in chunks */
@Override
public int getRenderDistance()
{
#if MC_VER <= MC_1_17_1
#if MC_VER <= MC_1_12_2
return MC.gameSettings.renderDistanceChunks;
#elif MC_VER <= MC_1_17_1
return MC.options.renderDistance;
#else
return MC.options.getEffectiveRenderDistance();
@@ -314,14 +357,18 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public int getFrameLimit()
{
#if MC_VER <= MC_1_18_2
#if MC_VER <= MC_1_12_2
return MC.gameSettings.limitFramerate;
#elif MC_VER <= MC_1_18_2
return MC.options.framerateLimit;
#else
return MC.options.framerateLimit().get();
#endif
}
#if MC_VER > MC_1_12_2
protected RenderTarget getRenderTarget() { return MC.getMainRenderTarget(); }
#endif
@Override
public boolean mcRendersToFrameBuffer()
@@ -352,7 +399,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
return this.finalLevelFrameBufferId;
}
#if MC_VER < MC_1_21_5
#if MC_VER <= MC_1_12_2
return MC.getFramebuffer().framebufferObject;
#elif MC_VER < MC_1_21_5
return this.getRenderTarget().frameBufferId;
#else
// MC renders to a texture and then directly to the default FBO now
@@ -367,7 +416,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public int getDepthTextureId()
{
#if MC_VER < MC_1_21_5
#if MC_VER <= MC_1_12_2
//1.12.2 is using renderbuffer instead of framebuffer for depth texture
return -1;
#elif MC_VER < MC_1_21_5
return this.getRenderTarget().getDepthTextureId();
#else
try
@@ -397,7 +449,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public int getColorTextureId()
{
#if MC_VER < MC_1_21_5
#if MC_VER <= MC_1_12_2
return MC.getFramebuffer().framebufferTexture;
#elif MC_VER < MC_1_21_5
return this.getRenderTarget().getColorTextureId();
#else
try
@@ -427,7 +481,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public int getTargetFramebufferViewportWidth()
{
#if MC_VER < MC_1_21_9
#if MC_VER <= MC_1_12_2
return MC.getFramebuffer().framebufferWidth;
#elif MC_VER < MC_1_21_9
return this.getRenderTarget().viewWidth;
#else
return this.getRenderTarget().width;
@@ -437,7 +493,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public int getTargetFramebufferViewportHeight()
{
#if MC_VER < MC_1_21_9
#if MC_VER <= MC_1_12_2
return MC.getFramebuffer().framebufferHeight;
#elif MC_VER < MC_1_21_9
return this.getRenderTarget().viewHeight;
#else
return this.getRenderTarget().height;
@@ -450,7 +508,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public boolean isFogStateSpecial()
{
#if MC_VER < MC_1_17_1
#if MC_VER <= MC_1_12_2
BlockPos blockPos = new BlockPos(MC.getRenderViewEntity().getPositionEyes(MC.getRenderPartialTicks()));
IBlockState fluidState = MC.getRenderViewEntity().world.getBlockState(blockPos);
return this.playerHasBlindingEffect() || fluidState.getMaterial().isLiquid() || fluidState.getBlock() instanceof IFluidBlock;
#elif MC_VER < MC_1_17_1
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
FluidState fluidState = camera.getFluidInCamera();
Entity entity = camera.getEntity();
@@ -468,6 +530,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
* It's better to use {@link MinecraftRenderWrapper#setLightmapId(int, IClientLevelWrapper)} if possible,
* however old MC versions don't support it.
*/
#if MC_VER > MC_1_12_2
public void updateLightmap(NativeImage lightPixels, IClientLevelWrapper level)
{
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
@@ -478,6 +541,8 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
wrapper.uploadLightmap(lightPixels);
}
#endif
public void setLightmapId(int tetxureId, IClientLevelWrapper level)
{
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
@@ -497,6 +562,9 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
{
default:
case AUTO:
#if MC_VER <= MC_1_12_2
// 1.12.2 has no getShade, fall through to ENABLED
#else
if (MC.level != null)
{
Direction mcDir = McObjectConverter.Convert(lodDirection);
@@ -506,7 +574,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
{
return 0.0f;
}
#endif
case ENABLED:
switch (lodDirection)
{
@@ -39,7 +39,9 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper
throw new IllegalStateException("Trying to get Installation Direction before dedicated server completed initialization!");
}
#if MC_VER < MC_1_21_1
#if MC_VER <= MC_1_12_2
return this.dedicatedServer.getDataDirectory();
#elif MC_VER < MC_1_21_1
return this.dedicatedServer.getServerDirectory();
#else
return this.dedicatedServer.getServerDirectory().toFile();
@@ -54,7 +56,7 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper
throw new IllegalStateException("Trying to get player count before dedicated server completed initialization!");
}
return this.dedicatedServer.getPlayerCount();
return this.dedicatedServer.#if MC_VER <= MC_1_12_2 getCurrentPlayerCount() #else getPlayerCount() #endif;
}
@@ -21,7 +21,11 @@ package com.seibel.distanthorizons.common.wrappers.minecraft;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
#if MC_VER <= MC_1_12_2
import net.minecraft.profiler.Profiler;
#else
import net.minecraft.util.profiling.ProfilerFiller;
#endif
/**
* @author James Seibel
@@ -29,21 +33,21 @@ import net.minecraft.util.profiling.ProfilerFiller;
*/
public class ProfilerWrapper implements IProfilerWrapper
{
public ProfilerFiller profiler;
public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler;
public ProfilerWrapper(ProfilerFiller newProfiler) { this.profiler = newProfiler; }
public ProfilerWrapper(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; }
/** starts a new section inside the currently running section */
@Override
public void push(String newSection) { this.profiler.push(newSection); }
public void push(String newSection) { this.profiler.#if MC_VER <= MC_1_12_2 startSection(newSection) #else push(newSection) #endif; }
/** ends the currently running section and starts a new one */
@Override
public void popPush(String newSection) { this.profiler.popPush(newSection); }
public void popPush(String newSection) { this.profiler.#if MC_VER <= MC_1_12_2 endStartSection(newSection) #else popPush(newSection) #endif; }
/** ends the currently running section */
@Override
public void pop() { this.profiler.pop(); }
public void pop() { this.profiler.#if MC_VER <= MC_1_12_2 endSection() #else pop() #endif; }
}

Some files were not shown because too many files have changed in this diff Show More