Merge branch 'main' of https://gitlab.com/jeseibel/minecraft-lod-mod
This commit is contained in:
@@ -10,6 +10,7 @@ stages:
|
||||
- build_1_19_4
|
||||
- build_1_20_1
|
||||
- build_1_19_2
|
||||
- api
|
||||
- pages
|
||||
|
||||
variables:
|
||||
@@ -155,6 +156,35 @@ build_1_20_1:
|
||||
allow_failure: true
|
||||
|
||||
|
||||
api:
|
||||
stage: api
|
||||
script:
|
||||
# this should only run for the API
|
||||
- ./gradlew api:clean --gradle-user-home cache/;
|
||||
# this also runs unit tests
|
||||
- ./gradlew api:build --gradle-user-home cache/;
|
||||
- ./gradlew api:addSourcesToCompiledJar --gradle-user-home cache/;
|
||||
image: eclipse-temurin:17
|
||||
artifacts:
|
||||
name: "Api_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
|
||||
paths:
|
||||
- coreSubProjects/api/build/libs/merged/*.jar
|
||||
# can be uncommented if we don't want a jar with the source code
|
||||
# - coreSubProjects/api/build/libs/*.jar
|
||||
exclude:
|
||||
- coreSubProjects/api/build/libs/merged/*-all.jar
|
||||
- coreSubProjects/api/build/libs/merged/*-sources.jar
|
||||
expire_in: 1 day
|
||||
when: always
|
||||
cache:
|
||||
key: "gradleCache"
|
||||
policy: pull-push
|
||||
paths:
|
||||
- .gradle
|
||||
- cache/
|
||||
allow_failure: true
|
||||
|
||||
|
||||
# generate and publish API javadocs
|
||||
pages:
|
||||
stage: pages
|
||||
|
||||
+2
-3
@@ -182,9 +182,6 @@ subprojects { p ->
|
||||
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
|
||||
implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}")
|
||||
|
||||
// Netty
|
||||
implementation("io.netty:netty-all:${rootProject.netty_version}")
|
||||
|
||||
// JOML
|
||||
implementation("org.joml:joml:${rootProject.joml_version}")
|
||||
|
||||
@@ -207,6 +204,8 @@ subprojects { p ->
|
||||
shadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
|
||||
shadowMe("com.formdev:flatlaf-extras:${rootProject.flatlaf_version}")
|
||||
|
||||
// Netty
|
||||
shadowMe("io.netty:netty-all:${rootProject.netty_version}")
|
||||
|
||||
// Remember, for lwjgl dependancies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing
|
||||
shadowMe("org.lwjgl:lwjgl-jawt:3.2.2") {
|
||||
|
||||
+12
-20
@@ -1,23 +1,15 @@
|
||||
@echo off
|
||||
@echo off & setlocal enabledelayedexpansion
|
||||
|
||||
echo Windows build all script needs to be rewritten
|
||||
echo I dont use Windows so I cant really make this
|
||||
echo So if someone does use Windows and knows how to script stuff then can you please port the "buildall" script I made for Unix
|
||||
@rem Loop trough everything in the version properties folder
|
||||
for %%f in (versionProperties\*) do (
|
||||
@rem Get the name of the version that is going to be compiled
|
||||
set version=%%~nf
|
||||
|
||||
@rem Clean out the folders and build it
|
||||
echo Cleaning workspace to build !version!
|
||||
call .\gradlew.bat clean -PmcVer="!version!" --no-daemon
|
||||
echo Building !version!
|
||||
call .\gradlew.bat build -PmcVer="!version!" --no-daemon
|
||||
)
|
||||
|
||||
|
||||
|
||||
@REM Old BAT script if you need some help with this task
|
||||
|
||||
@REM SETLOCAL
|
||||
@REM CALL :buildVersion "1.18.2"
|
||||
@REM CALL :buildVersion "1.19.4"
|
||||
@REM CALL :buildVersion "1.20.1"
|
||||
@REM EXIT /B %ERRORLEVEL%
|
||||
@REM
|
||||
@REM :buildVersion
|
||||
@REM @echo on
|
||||
@REM call ./gradlew.bat clean -PmcVer="%~1" --no-daemon
|
||||
@REM call ./gradlew.bat build -PmcVer="%~1" --no-daemon
|
||||
@REM @echo off
|
||||
@REM EXIT /B 0
|
||||
endlocal
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.seibel.distanthorizons.common.rendering;
|
||||
|
||||
#if PRE_MC_1_19_4
|
||||
import com.mojang.math.Matrix4f;
|
||||
#else
|
||||
import org.joml.Matrix4f;
|
||||
#endif
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class SeamlessOverdraw
|
||||
{
|
||||
/**
|
||||
* Proof-of-concept experimental option, not intended for normal use. <br>
|
||||
* (Poorly) replaces Minecraft's far clip plane so it lines up with DH's near clip plane.
|
||||
*/
|
||||
public static FloatBuffer overwriteMinecraftNearFarClipPlanes(Matrix4f minecraftProjectionMatrix, float previousPartialTicks)
|
||||
{
|
||||
FloatBuffer matrixFloatBuffer = FloatBuffer.allocate(16);
|
||||
|
||||
#if PRE_MC_1_19_4
|
||||
minecraftProjectionMatrix.store(matrixFloatBuffer);
|
||||
#else
|
||||
minecraftProjectionMatrix.get(matrixFloatBuffer);
|
||||
#endif
|
||||
|
||||
float[] matrixFloatArray = matrixFloatBuffer.array();
|
||||
|
||||
float dhFarClipPlane = RenderUtil.getNearClipPlaneDistanceInBlocks(previousPartialTicks);
|
||||
float farClip = dhFarClipPlane * 5.1f; // magic number found via trial and error, James has no idea what it represents, except that it makes the seam between DH and vanilla rendering pretty close
|
||||
float nearClip = 0.5f; // this causes issues with some vanilla rendering, specifically the wireframe around selected blocks is slightly off. Unfortunately the ratio between the near and far clip plane can't be easily modified without completely screwing up the rendering.
|
||||
|
||||
// these may be the wrong index locations in any version of MC other than 1.18.2
|
||||
matrixFloatArray[10] = -((farClip + nearClip) / (farClip - nearClip)); // near clip plane
|
||||
matrixFloatArray[11] = -((2 * farClip * nearClip) / (farClip - nearClip)); // far clip plane
|
||||
|
||||
matrixFloatBuffer = FloatBuffer.wrap(matrixFloatArray);
|
||||
return matrixFloatBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,9 @@
|
||||
package com.seibel.distanthorizons.common.wrappers;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.level.KeyedClientLevelManager;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftDedicatedServerWrapper;
|
||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
@@ -49,6 +51,7 @@ public class DependencySetup {
|
||||
SingletonInjector.INSTANCE.bind(ILangWrapper.class, LangWrapper.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IVersionConstants.class, VersionConstants.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IWrapperFactory.class, WrapperFactory.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IKeyedClientLevelManager.class, KeyedClientLevelManager.INSTANCE);
|
||||
DependencySetupDoneCheck.isDone = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public class WrapperFactory implements IWrapperFactory
|
||||
}
|
||||
}
|
||||
|
||||
// MC 1.18
|
||||
// MC 1.18, 1.19, 1.20
|
||||
#if POST_MC_1_17_1
|
||||
else if (objectArray.length == 2)
|
||||
{
|
||||
@@ -123,7 +123,11 @@ public class WrapperFactory implements IWrapperFactory
|
||||
#else
|
||||
// Intentional compiler error to bring attention to the missing wrapper function.
|
||||
// If you need to work on an unimplemented version but don't have the ability to implement this yet
|
||||
// you can comment it out, but please don't commit it. Someone will have to implement it
|
||||
// you can comment it out, but please don't commit it. Someone will have to implement it .
|
||||
|
||||
// After implementing the new version please read this method's javadocs for instructions
|
||||
// on what other locations also need to be updated, the DhAPI specifically needs to
|
||||
// be updated to state which objects this method accepts.
|
||||
not implemented for this version of Minecraft!
|
||||
#endif
|
||||
}
|
||||
@@ -137,7 +141,7 @@ public class WrapperFactory implements IWrapperFactory
|
||||
"Chunk wrapper creation failed. \n" +
|
||||
"Expected parameters: \n");
|
||||
|
||||
// MC 1.18
|
||||
// MC 1.18, 1.19, 1.20
|
||||
#if POST_MC_1_17_1
|
||||
message.append("["+ChunkAccess.class.getName()+"], \n");
|
||||
message.append("["+LevelReader.class.getName()+"]. \n");
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.level;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
{
|
||||
public static final KeyedClientLevelManager INSTANCE = new KeyedClientLevelManager();
|
||||
|
||||
/** This is set and managed by the ClientApi for servers with support for DH. */
|
||||
private IServerKeyedClientLevel overrideWrapper = null;
|
||||
private boolean useOverrideWrapper = false;
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
private KeyedClientLevelManager() { }
|
||||
|
||||
|
||||
|
||||
//======================//
|
||||
// level override logic //
|
||||
//======================//
|
||||
|
||||
@Override
|
||||
public void setServerKeyedLevel(IServerKeyedClientLevel clientLevel) { this.overrideWrapper = clientLevel; }
|
||||
@Override
|
||||
public IServerKeyedClientLevel getOverrideWrapper() { return this.overrideWrapper; }
|
||||
|
||||
@Override
|
||||
public IServerKeyedClientLevel getServerKeyedLevel(ILevelWrapper level, String serverLevelKey)
|
||||
{
|
||||
Objects.requireNonNull(level);
|
||||
Objects.requireNonNull(serverLevelKey);
|
||||
return new ServerKeyedClientLevel((ClientLevel) level.getWrappedMcObject(), serverLevelKey);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setUseOverrideWrapper(boolean useOverrideWrapper) { this.useOverrideWrapper = useOverrideWrapper; }
|
||||
@Override
|
||||
public boolean getUseOverrideWrapper() { return this.useOverrideWrapper; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.level;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
public class ServerKeyedClientLevel extends ClientLevelWrapper implements IServerKeyedClientLevel
|
||||
{
|
||||
/** A unique identifier (generally the level's name) for differentiating multiverse levels */
|
||||
private final String serverLevelKey;
|
||||
|
||||
public ServerKeyedClientLevel(ClientLevel level, String serverLevelKey)
|
||||
{
|
||||
super(level);
|
||||
this.serverLevelKey = serverLevelKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerLevelKey() { return this.serverLevelKey; }
|
||||
|
||||
}
|
||||
+5
-1
@@ -186,7 +186,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
return null;
|
||||
}
|
||||
|
||||
return ClientLevelWrapper.getWrapper(mc.level);
|
||||
return ClientLevelWrapper.getWrapperIgnoringOverride(this.mc.level);
|
||||
}
|
||||
|
||||
/** Please move over to getInstallationDirectory() */
|
||||
@@ -267,4 +267,8 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
public File getInstallationDirectory() {
|
||||
return mc.gameDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnRenderThread(Runnable runnable) { this.mc.execute(runnable); }
|
||||
|
||||
}
|
||||
|
||||
+95
-75
@@ -8,6 +8,8 @@ import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.cache.ClientBlockDetailMap;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
@@ -28,30 +30,48 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version 2023-6-3
|
||||
*/
|
||||
public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(ClientLevelWrapper.class.getSimpleName());
|
||||
private static final ConcurrentHashMap<ClientLevel, ClientLevelWrapper>
|
||||
levelWrapperMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static ClientLevelWrapper getWrapper(ClientLevel level) {
|
||||
return levelWrapperMap.computeIfAbsent(level, ClientLevelWrapper::new);
|
||||
}
|
||||
public static void closeWrapper(ClientLevel level)
|
||||
{
|
||||
levelWrapperMap.remove(level);
|
||||
}
|
||||
|
||||
private ClientLevelWrapper(ClientLevel level) {
|
||||
this.level = level;
|
||||
}
|
||||
final ClientLevel level;
|
||||
ClientBlockDetailMap blockMap = new ClientBlockDetailMap(this);
|
||||
@Nullable
|
||||
private static final ConcurrentHashMap<ClientLevel, ClientLevelWrapper> LEVEL_WRAPPER_BY_CLIENT_LEVEL = new ConcurrentHashMap<>();
|
||||
private static final IKeyedClientLevelManager KEYED_CLIENT_LEVEL_MANAGER = SingletonInjector.INSTANCE.get(IKeyedClientLevelManager.class);
|
||||
|
||||
private final ClientLevel level;
|
||||
private final ClientBlockDetailMap blockMap = new ClientBlockDetailMap(this);
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
protected ClientLevelWrapper(ClientLevel level) { this.level = level; }
|
||||
|
||||
|
||||
|
||||
//===============//
|
||||
// wrapper logic //
|
||||
//===============//
|
||||
|
||||
public static IClientLevelWrapper getWrapper(ClientLevel level)
|
||||
{
|
||||
// used if the client is connected to a server that defines the currently loaded level
|
||||
if (KEYED_CLIENT_LEVEL_MANAGER.getUseOverrideWrapper())
|
||||
{
|
||||
return KEYED_CLIENT_LEVEL_MANAGER.getOverrideWrapper();
|
||||
}
|
||||
|
||||
return getWrapperIgnoringOverride(level);
|
||||
}
|
||||
public static IClientLevelWrapper getWrapperIgnoringOverride(ClientLevel level)
|
||||
{
|
||||
return LEVEL_WRAPPER_BY_CLIENT_LEVEL.computeIfAbsent(level, ClientLevelWrapper::new);
|
||||
}
|
||||
|
||||
public static void closeLevel(ClientLevel level) { LEVEL_WRAPPER_BY_CLIENT_LEVEL.remove(level); }
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IServerLevelWrapper tryGetServerSideWrapper()
|
||||
{
|
||||
@@ -89,58 +109,46 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
}
|
||||
}
|
||||
public static void cleanCheck() {
|
||||
if (!levelWrapperMap.isEmpty()) {
|
||||
LOGGER.warn("{} client levels havn't been freed!", levelWrapperMap.size());
|
||||
levelWrapperMap.clear();
|
||||
if (!LEVEL_WRAPPER_BY_CLIENT_LEVEL.isEmpty()) {
|
||||
LOGGER.warn("{} client levels havn't been freed!", LEVEL_WRAPPER_BY_CLIENT_LEVEL.size());
|
||||
LEVEL_WRAPPER_BY_CLIENT_LEVEL.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//====================//
|
||||
// base level methods //
|
||||
//====================//
|
||||
|
||||
@Override
|
||||
public int computeBaseColor(DhBlockPos pos, IBiomeWrapper biome, IBlockStateWrapper blockState) {
|
||||
return blockMap.getColor(((BlockStateWrapper)blockState).blockState,
|
||||
(BiomeWrapper)biome, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDhApiDimensionTypeWrapper getDimensionType()
|
||||
public int computeBaseColor(DhBlockPos pos, IBiomeWrapper biome, IBlockStateWrapper blockState)
|
||||
{
|
||||
return DimensionTypeWrapper.getDimensionTypeWrapper(level.dimensionType());
|
||||
return this.blockMap.getColor(((BlockStateWrapper)blockState).blockState, (BiomeWrapper)biome, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDhApiDimensionTypeWrapper getDimensionType() { return DimensionTypeWrapper.getDimensionTypeWrapper(this.level.dimensionType()); }
|
||||
|
||||
@Override
|
||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; }
|
||||
|
||||
@Override
|
||||
public int getBlockLight(int x, int y, int z)
|
||||
{
|
||||
return level.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z));
|
||||
}
|
||||
public int getBlockLight(int x, int y, int z) { return this.level.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); }
|
||||
|
||||
@Override
|
||||
public int getSkyLight(int x, int y, int z)
|
||||
{
|
||||
return level.getBrightness(LightLayer.SKY, new BlockPos(x,y,z));
|
||||
}
|
||||
public int getSkyLight(int x, int y, int z) { return this.level.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); }
|
||||
|
||||
public ClientLevel getLevel()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
public ClientLevel getLevel() { return this.level; }
|
||||
|
||||
@Override
|
||||
public boolean hasCeiling() {
|
||||
return level.dimensionType().hasCeiling();
|
||||
}
|
||||
public boolean hasCeiling() { return this.level.dimensionType().hasCeiling(); }
|
||||
|
||||
@Override
|
||||
public boolean hasSkyLight() {
|
||||
return level.dimensionType().hasSkyLight();
|
||||
}
|
||||
public boolean hasSkyLight() { return this.level.dimensionType().hasSkyLight(); }
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return level.getHeight();
|
||||
}
|
||||
public int getHeight() { return this.level.getHeight(); }
|
||||
|
||||
@Override
|
||||
public int getMinHeight()
|
||||
@@ -148,43 +156,55 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
#if PRE_MC_1_17_1
|
||||
return 0;
|
||||
#else
|
||||
return level.getMinBuildHeight();
|
||||
return this.level.getMinBuildHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkWrapper tryGetChunk(DhChunkPos pos) {
|
||||
if (!level.hasChunk(pos.x, pos.z)) return null;
|
||||
ChunkAccess chunk = level.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false);
|
||||
if (chunk == null) return null;
|
||||
return new ChunkWrapper(chunk, level, this);
|
||||
public IChunkWrapper tryGetChunk(DhChunkPos pos)
|
||||
{
|
||||
if (!this.level.hasChunk(pos.x, pos.z))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ChunkAccess chunk = this.level.getChunk(pos.x, pos.z, ChunkStatus.EMPTY, false);
|
||||
if (chunk == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ChunkWrapper(chunk, this.level, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChunkLoaded(int chunkX, int chunkZ) {
|
||||
ChunkSource source = level.getChunkSource();
|
||||
public boolean hasChunkLoaded(int chunkX, int chunkZ)
|
||||
{
|
||||
ChunkSource source = this.level.getChunkSource();
|
||||
return source.hasChunk(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockStateWrapper getBlockState(DhBlockPos pos) {
|
||||
return BlockStateWrapper.fromBlockState(level.getBlockState(McObjectConverter.Convert(pos)));
|
||||
}
|
||||
public IBlockStateWrapper getBlockState(DhBlockPos pos)
|
||||
{
|
||||
return BlockStateWrapper.fromBlockState(this.level.getBlockState(McObjectConverter.Convert(pos)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBiomeWrapper getBiome(DhBlockPos pos) {
|
||||
return BiomeWrapper.getBiomeWrapper(level.getBiome(McObjectConverter.Convert(pos)));
|
||||
}
|
||||
public IBiomeWrapper getBiome(DhBlockPos pos) { return BiomeWrapper.getBiomeWrapper(this.level.getBiome(McObjectConverter.Convert(pos))); }
|
||||
|
||||
@Override
|
||||
public ClientLevel getWrappedMcObject()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
public ClientLevel getWrappedMcObject() { return this.level; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Wrapped{" + level.toString() + "@" + getDimensionType().getDimensionName() + "}";
|
||||
}
|
||||
public String toString()
|
||||
{
|
||||
if (this.level == null)
|
||||
{
|
||||
return "Wrapped{null}";
|
||||
}
|
||||
|
||||
return "Wrapped{" + this.level.toString() + "@" + this.getDimensionType().getDimensionName() + "}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
}
|
||||
|
||||
@Override
|
||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.CLIENT_LEVEL; }
|
||||
public EDhApiLevelType getLevelType() { return EDhApiLevelType.SERVER_LEVEL; }
|
||||
|
||||
@Override
|
||||
public int getBlockLight(int x, int y, int z)
|
||||
|
||||
+82
-28
@@ -20,6 +20,8 @@
|
||||
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.*;
|
||||
@@ -191,7 +193,21 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
|
||||
public static ThreadLocal<Boolean> isDistantGeneratorThread = new ThreadLocal<>();
|
||||
public static ThreadLocal<Object> onDistantGenerationMixinData = new ThreadLocal<>();
|
||||
public static boolean isCurrentThreadDistantGeneratorThread() { return (isDistantGeneratorThread.get() != null); }
|
||||
public static void putDistantGenerationMixinData(Object data) {
|
||||
LodUtil.assertTrue(isCurrentThreadDistantGeneratorThread());
|
||||
onDistantGenerationMixinData.set(data);
|
||||
}
|
||||
public static Object getDistantGenerationMixinData() {
|
||||
LodUtil.assertTrue(isCurrentThreadDistantGeneratorThread());
|
||||
return onDistantGenerationMixinData.get();
|
||||
}
|
||||
|
||||
public static void clearDistantGenerationMixinData() {
|
||||
LodUtil.assertTrue(isCurrentThreadDistantGeneratorThread());
|
||||
onDistantGenerationMixinData.remove();
|
||||
}
|
||||
|
||||
public static final DhThreadFactory threadFactory = new DhThreadFactory("DH-Gen-Worker-Thread", Thread.MIN_PRIORITY);
|
||||
|
||||
@@ -200,10 +216,35 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
//==============//
|
||||
// constructors //
|
||||
//==============//
|
||||
|
||||
|
||||
public static ImmutableMap<EDhApiWorldGenerationStep, Integer> BorderNeeded;
|
||||
public static int MaxBorderNeeded;
|
||||
|
||||
static
|
||||
{
|
||||
DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
boolean isTerraFirmaCraft = false;
|
||||
try {
|
||||
Class.forName("net.dries007.tfc.world.TFCChunkGenerator");
|
||||
isTerraFirmaCraft = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
//Ignore
|
||||
}
|
||||
EVENT_LOGGER.info("DH TerraFirmaCraft detection: " + isTerraFirmaCraft);
|
||||
ImmutableMap.Builder<EDhApiWorldGenerationStep, Integer> builder = ImmutableMap.builder();
|
||||
builder.put(EDhApiWorldGenerationStep.EMPTY, 1);
|
||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_START, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_REFERENCE, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.BIOMES, isTerraFirmaCraft ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.NOISE, isTerraFirmaCraft ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.SURFACE, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.CARVERS, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.LIQUID_CARVERS, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.FEATURES, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.LIGHT, 0);
|
||||
BorderNeeded = builder.build();
|
||||
MaxBorderNeeded = BorderNeeded.values().stream().mapToInt(Integer::intValue).max().getAsInt();
|
||||
}
|
||||
|
||||
public BatchGenerationEnvironment(IDhServerLevel serverlevel)
|
||||
@@ -219,12 +260,17 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
if (generator.getClass().toString().equals("class com.terraforged.mod.chunk.TFChunkGenerator"))
|
||||
{
|
||||
EVENT_LOGGER.info("TerraForge Chunk Generator detected: ["+generator.getClass()+"], Distant Generation will try its best to support it.");
|
||||
EVENT_LOGGER.info("If it does crash, turn Distant Generation off or set it to to ["+EDhApiWorldGenerationStep.EMPTY+"].");
|
||||
EVENT_LOGGER.info("If it does crash, turn Distant Generation off or set it to to ["+EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY+"].");
|
||||
}
|
||||
else if (generator.getClass().toString().equals("class net.dries007.tfc.world.TFCChunkGenerator"))
|
||||
{
|
||||
EVENT_LOGGER.info("TerraFirmaCraft Chunk Generator detected: ["+generator.getClass()+"], Distant Generation will try its best to support it.");
|
||||
EVENT_LOGGER.info("If it does crash, turn Distant Generation off or set it to to ["+ EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY +"].");
|
||||
}
|
||||
else
|
||||
{
|
||||
EVENT_LOGGER.warn("Unknown Chunk Generator detected: ["+generator.getClass()+"], Distant Generation May Fail!");
|
||||
EVENT_LOGGER.warn("If it does crash, disable Distant Generation or set the Generation Mode to ["+EDhApiWorldGenerationStep.EMPTY+"].");
|
||||
EVENT_LOGGER.warn("If it does crash, disable Distant Generation or set the Generation Mode to ["+EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY+"].");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,20 +403,29 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static ArrayGridList<ChunkAccess> GetCutoutFrom(ArrayGridList<ChunkAccess> total, int border) {
|
||||
return new ArrayGridList<>(total, border, total.gridSize - border);
|
||||
}
|
||||
|
||||
private static ArrayGridList<ChunkAccess> GetCutoutFrom(ArrayGridList<ChunkAccess> total, EDhApiWorldGenerationStep step) {
|
||||
return GetCutoutFrom(total, MaxBorderNeeded - BorderNeeded.get(step));
|
||||
}
|
||||
|
||||
public void generateLodFromList(GenerationEvent genEvent) throws InterruptedException
|
||||
{
|
||||
EVENT_LOGGER.debug("Lod Generate Event: "+genEvent.minPos);
|
||||
|
||||
ArrayGridList<ChunkAccess> referencedChunks;
|
||||
ArrayGridList<ChunkAccess> genChunks;
|
||||
ArrayGridList<ChunkAccess> totalChunks;
|
||||
ArrayGridList<ChunkAccess> finalGenChunks;
|
||||
LightedWorldGenRegion region;
|
||||
WorldGenLevelLightEngine lightEngine;
|
||||
LightGetterAdaptor adaptor;
|
||||
|
||||
int refSize = genEvent.size+2; // +2 for the border referenced chunks
|
||||
int refPosX = genEvent.minPos.x - 1; // -1 for the border referenced chunks
|
||||
int refPosZ = genEvent.minPos.z - 1; // -1 for the border referenced chunks
|
||||
|
||||
int borderSize = MaxBorderNeeded;
|
||||
int refSize = genEvent.size + borderSize * 2;
|
||||
int refPosX = genEvent.minPos.x - borderSize;
|
||||
int refPosZ = genEvent.minPos.z - borderSize;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -399,17 +454,15 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
referencedChunks = new ArrayGridList<>(refSize, (x,z) -> generator.generate(x + refPosX,z + refPosZ));
|
||||
|
||||
totalChunks = new ArrayGridList<>(refSize, (x,z) -> generator.generate(x + refPosX,z + refPosZ));
|
||||
|
||||
genEvent.refreshTimeout();
|
||||
region = new LightedWorldGenRegion(params.level, lightEngine, referencedChunks,
|
||||
region = new LightedWorldGenRegion(params.level, lightEngine, totalChunks,
|
||||
ChunkStatus.STRUCTURE_STARTS, refSize/2, generator);
|
||||
adaptor.setRegion(region);
|
||||
genEvent.threadedParam.makeStructFeat(region, params);
|
||||
genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION,
|
||||
referencedChunks.gridSize - RANGE_TO_RANGE_EMPTY_EXTENSION);
|
||||
this.generateDirect(genEvent, genChunks, genEvent.targetGenerationStep, region);
|
||||
this.generateDirect(genEvent, totalChunks, borderSize, genEvent.targetGenerationStep, region);
|
||||
genEvent.timer.nextEvent("cleanup");
|
||||
}
|
||||
catch (StepStructureStart.StructStartCorruptedException f)
|
||||
@@ -417,12 +470,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
genEvent.threadedParam.markAsInvalid();
|
||||
throw (RuntimeException)f.getCause();
|
||||
}
|
||||
|
||||
for (int offsetY = 0; offsetY < genChunks.gridSize; offsetY++)
|
||||
|
||||
finalGenChunks = GetCutoutFrom(totalChunks, borderSize);
|
||||
for (int offsetY = 0; offsetY < finalGenChunks.gridSize; offsetY++)
|
||||
{
|
||||
for (int offsetX = 0; offsetX < genChunks.gridSize; offsetX++)
|
||||
for (int offsetX = 0; offsetX < finalGenChunks.gridSize; offsetX++)
|
||||
{
|
||||
ChunkAccess target = genChunks.get(offsetX, offsetY);
|
||||
ChunkAccess target = finalGenChunks.get(offsetX, offsetY);
|
||||
ChunkWrapper wrappedChunk = new ChunkWrapper(target, region, null);
|
||||
if (target instanceof LevelChunk) {
|
||||
((LevelChunk) target).loaded = true;
|
||||
@@ -472,7 +526,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
}
|
||||
|
||||
public void generateDirect(GenerationEvent genEvent, ArrayGridList<ChunkAccess> chunksToGenerate,
|
||||
public void generateDirect(GenerationEvent genEvent, ArrayGridList<ChunkAccess> chunksToGenerate, int border,
|
||||
EDhApiWorldGenerationStep step, LightedWorldGenRegion region) throws InterruptedException
|
||||
{
|
||||
if (Thread.interrupted())
|
||||
@@ -500,7 +554,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
genEvent.timer.nextEvent("structStart");
|
||||
throwIfThreadInterrupted();
|
||||
stepStructureStart.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
stepStructureStart.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunksToGenerate, EDhApiWorldGenerationStep.STRUCTURE_START));
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.STRUCTURE_START)
|
||||
{
|
||||
@@ -509,7 +563,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
genEvent.timer.nextEvent("structRef");
|
||||
throwIfThreadInterrupted();
|
||||
stepStructureReference.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
stepStructureReference.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunksToGenerate, EDhApiWorldGenerationStep.STRUCTURE_REFERENCE));
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.STRUCTURE_REFERENCE)
|
||||
{
|
||||
@@ -518,7 +572,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
genEvent.timer.nextEvent("biome");
|
||||
throwIfThreadInterrupted();
|
||||
stepBiomes.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
stepBiomes.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunksToGenerate, EDhApiWorldGenerationStep.BIOMES));
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.BIOMES)
|
||||
{
|
||||
@@ -527,7 +581,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
genEvent.timer.nextEvent("noise");
|
||||
throwIfThreadInterrupted();
|
||||
stepNoise.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
stepNoise.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunksToGenerate, EDhApiWorldGenerationStep.NOISE));
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.NOISE)
|
||||
{
|
||||
@@ -536,7 +590,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
genEvent.timer.nextEvent("surface");
|
||||
throwIfThreadInterrupted();
|
||||
stepSurface.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
stepSurface.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunksToGenerate, EDhApiWorldGenerationStep.SURFACE));
|
||||
genEvent.refreshTimeout();
|
||||
if (step == EDhApiWorldGenerationStep.SURFACE)
|
||||
{
|
||||
@@ -552,7 +606,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
genEvent.timer.nextEvent("feature");
|
||||
throwIfThreadInterrupted();
|
||||
stepFeatures.generateGroup(genEvent.threadedParam, region, chunksToGenerate);
|
||||
stepFeatures.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunksToGenerate, EDhApiWorldGenerationStep.FEATURES));
|
||||
genEvent.refreshTimeout();
|
||||
}
|
||||
finally
|
||||
@@ -566,7 +620,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
if (!Thread.interrupted())
|
||||
{
|
||||
this.stepLight.generateGroup(region.getLightEngine(), chunksToGenerate);
|
||||
this.stepLight.generateGroup(region.getLightEngine(), GetCutoutFrom(chunksToGenerate, EDhApiWorldGenerationStep.LIGHT));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ public class LightedWorldGenRegion extends WorldGenRegion
|
||||
}
|
||||
|
||||
// Use this instead of super.hasChunk() to bypass C2ME concurrency checks
|
||||
private boolean superHasChunk(int x, int z) {
|
||||
public boolean superHasChunk(int x, int z) {
|
||||
int k = x - firstPos.x;
|
||||
int l = z - firstPos.z;
|
||||
return l >= 0 && l < size && k >= 0 && k < size;
|
||||
|
||||
+3
-1
@@ -31,7 +31,7 @@ import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
#if POST_MC_1_18_2
|
||||
#if POST_MC_1_18_2
|
||||
#endif
|
||||
|
||||
public final class StepFeatures {
|
||||
@@ -66,10 +66,12 @@ public final class StepFeatures {
|
||||
worldGenRegion.setOverrideCenter(chunk.getPos());
|
||||
environment.params.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeat);
|
||||
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
|
||||
BatchGenerationEnvironment.clearDistantGenerationMixinData();
|
||||
#else
|
||||
environment.params.generator.applyBiomeDecoration(worldGenRegion, chunk,
|
||||
tParams.structFeat.forWorldGenRegion(worldGenRegion));
|
||||
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
|
||||
BatchGenerationEnvironment.clearDistantGenerationMixinData();
|
||||
#endif
|
||||
} catch (ReportedException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 83ab7e46b3...730216b761
+1
-1
@@ -59,8 +59,8 @@ dependencies {
|
||||
addModJar(fabricApi.module("fabric-key-binding-api-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy)
|
||||
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version))
|
||||
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
|
||||
|
||||
// Mod Menu
|
||||
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}")
|
||||
|
||||
@@ -19,33 +19,43 @@
|
||||
|
||||
package com.seibel.distanthorizons.fabric;
|
||||
|
||||
import com.seibel.distanthorizons.common.rendering.SeamlessOverdraw;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.fabric.wrappers.modAccessor.ImmersivePortalsAccessor;
|
||||
import com.seibel.distanthorizons.fabric.wrappers.modAccessor.SodiumAccessor;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
@@ -100,7 +110,7 @@ public class FabricClientProxy
|
||||
//#if PRE_MC_1_18_2 // in 1.18+, we use mixin hook in setClientLightReady(true)
|
||||
ClientChunkEvents.CHUNK_LOAD.register((level, chunk) ->
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
@@ -119,7 +129,7 @@ public class FabricClientProxy
|
||||
{
|
||||
// LOGGER.info("attack block at blockpos: " + blockPos);
|
||||
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
@@ -146,7 +156,7 @@ public class FabricClientProxy
|
||||
{
|
||||
// LOGGER.info("use block at blockpos: " + hitResult.getBlockPos());
|
||||
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
@@ -163,7 +173,7 @@ public class FabricClientProxy
|
||||
// ClientChunkSaveEvent
|
||||
ClientChunkEvents.CHUNK_UNLOAD.register((level, chunk) ->
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level);
|
||||
ClientApi.INSTANCE.clientChunkSaveEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
@@ -188,10 +198,23 @@ public class FabricClientProxy
|
||||
}
|
||||
else
|
||||
{
|
||||
clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
this.clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
McObjectConverter.Convert(renderContext.matrixStack().last().pose()),
|
||||
McObjectConverter.Convert(renderContext.projectionMatrix()),
|
||||
renderContext.tickDelta());
|
||||
|
||||
|
||||
// experimental proof-of-concept option
|
||||
if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get())
|
||||
{
|
||||
FloatBuffer modifiedMatrixBuffer = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(renderContext.projectionMatrix(), renderContext.tickDelta());
|
||||
|
||||
#if PRE_MC_1_19_4
|
||||
renderContext.projectionMatrix().load(modifiedMatrixBuffer);
|
||||
#else
|
||||
renderContext.projectionMatrix().set(modifiedMatrixBuffer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (immersiveAccessor != null)
|
||||
@@ -209,6 +232,12 @@ public class FabricClientProxy
|
||||
onKeyInput();
|
||||
}
|
||||
});
|
||||
|
||||
ClientPlayNetworking.registerGlobalReceiver(new ResourceLocation("distant_horizons", "world_control"), // TODO move these strings into a constant somewhere
|
||||
(Minecraft client, ClientPacketListener handler, FriendlyByteBuf byteBuffer, PacketSender responseSender) ->
|
||||
{
|
||||
ClientApi.INSTANCE.serverMessageReceived(byteBuffer);
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isValidTime() { return !(Minecraft.getInstance().screen instanceof TitleScreen); }
|
||||
|
||||
@@ -5,19 +5,24 @@ import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||
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.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.api.internal.ServerApi;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -36,31 +41,31 @@ public class FabricServerProxy
|
||||
{
|
||||
private static final ServerApi SERVER_API = ServerApi.INSTANCE;
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
|
||||
private final boolean isDedicated;
|
||||
public static Supplier<Boolean> isGenerationThreadChecker = null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FabricServerProxy(boolean isDedicated)
|
||||
{
|
||||
this.isDedicated = isDedicated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean isValidTime()
|
||||
{
|
||||
if (isDedicated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//FIXME: This may cause init issue...
|
||||
return !(Minecraft.getInstance().screen instanceof TitleScreen);
|
||||
}
|
||||
|
||||
private ClientLevelWrapper getClientLevelWrapper(ClientLevel level) { return ClientLevelWrapper.getWrapper(level); }
|
||||
|
||||
private IClientLevelWrapper getClientLevelWrapper(ClientLevel level) { return ClientLevelWrapper.getWrapper(level); }
|
||||
private ServerLevelWrapper getServerLevelWrapper(ServerLevel level) { return ServerLevelWrapper.getWrapper(level); }
|
||||
private ServerPlayerWrapper getServerPlayerWrapper(ServerPlayer player) { return ServerPlayerWrapper.getWrapper(player); }
|
||||
|
||||
@@ -69,15 +74,15 @@ public class FabricServerProxy
|
||||
{
|
||||
LOGGER.info("Registering Fabric Server Events");
|
||||
isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
|
||||
/* Register the mod needed event callbacks */
|
||||
|
||||
|
||||
// ServerTickEvent
|
||||
ServerTickEvents.END_SERVER_TICK.register((server) -> SERVER_API.serverTickEvent());
|
||||
|
||||
|
||||
// ServerWorldLoadEvent
|
||||
//TODO: Check if both of these use the correct timed events. (i.e. is it 'ed' or 'ing' one?)
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((server) ->
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
@@ -85,16 +90,16 @@ public class FabricServerProxy
|
||||
}
|
||||
});
|
||||
// ServerWorldUnloadEvent
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register((server) ->
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register((server) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverUnloadEvent();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// ServerLevelLoadEvent
|
||||
ServerWorldEvents.LOAD.register((server, level) ->
|
||||
ServerWorldEvents.LOAD.register((server, level) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
@@ -102,16 +107,16 @@ public class FabricServerProxy
|
||||
}
|
||||
});
|
||||
// ServerLevelUnloadEvent
|
||||
ServerWorldEvents.UNLOAD.register((server, level) ->
|
||||
ServerWorldEvents.UNLOAD.register((server, level) ->
|
||||
{
|
||||
if (isValidTime())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLevelUnloadEvent(getServerLevelWrapper(level));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// ServerChunkLoadEvent
|
||||
ServerChunkEvents.CHUNK_LOAD.register((server, chunk) ->
|
||||
ServerChunkEvents.CHUNK_LOAD.register((server, chunk) ->
|
||||
{
|
||||
ILevelWrapper level = getServerLevelWrapper((ServerLevel) chunk.getLevel());
|
||||
if (isValidTime())
|
||||
@@ -138,4 +143,5 @@ public class FabricServerProxy
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package com.seibel.distanthorizons.fabric.mixins.client;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
@@ -58,10 +58,10 @@ public class MixinClientPacketListener
|
||||
@Inject(method = "enableChunkLight", at = @At("TAIL"))
|
||||
void onEnableChunkLight(LevelChunk chunk, int x, int z, CallbackInfo ci)
|
||||
{
|
||||
ClientLevelWrapper clientLevel = ClientLevelWrapper.getWrapper((ClientLevel) chunk.getLevel());
|
||||
IClientLevelWrapper clientLevel = ClientLevelWrapper.getWrapper((ClientLevel) chunk.getLevel());
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(new ChunkWrapper(chunk, chunk.getLevel(), clientLevel), clientLevel);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
+12
-3
@@ -1,5 +1,6 @@
|
||||
package com.seibel.distanthorizons.fabric.mixins.client;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -18,14 +19,22 @@ public class MixinGameRenderer
|
||||
#if POST_MC_1_17_1
|
||||
@Inject(method = "shutdownShaders", at = @At("HEAD"))
|
||||
public void onShutdownShaders(CallbackInfo ci) {
|
||||
LOGGER.info("Shutting down renderer");
|
||||
LOGGER.info("Shutting down renderer (fabric)");
|
||||
if (!DependencySetupDoneCheck.isDone) {
|
||||
LOGGER.warn("Dependency setup is not done yet, skipping renderer this shutdown event!");
|
||||
return;
|
||||
}
|
||||
ClientApi.INSTANCE.rendererShutdownEvent();
|
||||
}
|
||||
|
||||
// FIXME: This I think will dup multiple renderStartupEvent calls...
|
||||
@Inject(method = {"reloadShaders", "preloadUiShader", "preloadShader"}, at = @At("TAIL"))
|
||||
@Inject(method = {"reloadShaders", "preloadUiShader"}, at = @At("TAIL"))
|
||||
public void onStartupShaders(CallbackInfo ci) {
|
||||
LOGGER.info("Starting up renderer");
|
||||
LOGGER.info("Starting up renderer (fabric)");
|
||||
if (!DependencySetupDoneCheck.isDone) {
|
||||
LOGGER.warn("Dependency setup is not done yet, skipping renderer this startup event!");
|
||||
return;
|
||||
}
|
||||
ClientApi.INSTANCE.rendererStartupEvent();
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -85,6 +85,8 @@ dependencies {
|
||||
|
||||
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
|
||||
|
||||
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
|
||||
|
||||
// if (System.getProperty("idea.sync.active") != "true") {
|
||||
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
|
||||
// }
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -95,7 +96,7 @@ public class ForgeClientProxy
|
||||
{
|
||||
if (GetLevel(event) instanceof ClientLevel)
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event));
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event));
|
||||
IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetLevel(event), wrappedLevel);
|
||||
ClientApi.INSTANCE.clientChunkLoadEvent(chunk, ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event)));
|
||||
}
|
||||
@@ -105,7 +106,7 @@ public class ForgeClientProxy
|
||||
{
|
||||
if (GetLevel(event) instanceof ClientLevel)
|
||||
{
|
||||
ClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event));
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event));
|
||||
IChunkWrapper chunk = new ChunkWrapper(event.getChunk() , GetLevel(event), wrappedLevel);
|
||||
ClientApi.INSTANCE.clientChunkSaveEvent(chunk, ClientLevelWrapper.getWrapper((ClientLevel) GetLevel(event)));
|
||||
}
|
||||
|
||||
+12
-3
@@ -1,5 +1,6 @@
|
||||
package com.seibel.distanthorizons.forge.mixins.client;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -18,14 +19,22 @@ public class MixinGameRenderer
|
||||
#if POST_MC_1_17_1
|
||||
@Inject(method = "shutdownShaders", at = @At("HEAD"))
|
||||
public void onShutdownShaders(CallbackInfo ci) {
|
||||
LOGGER.info("Shutting down renderer");
|
||||
LOGGER.info("Shutting down renderer (forge)");
|
||||
if (!DependencySetupDoneCheck.isDone) {
|
||||
LOGGER.warn("Dependency setup is not done yet, skipping renderer this shutdown event!");
|
||||
return;
|
||||
}
|
||||
ClientApi.INSTANCE.rendererShutdownEvent();
|
||||
}
|
||||
|
||||
// FIXME: This I think will dup multiple renderStartupEvent calls...
|
||||
@Inject(method = {"reloadShaders", "preloadUiShader", "preloadShader"}, at = @At("TAIL"))
|
||||
@Inject(method = {"reloadShaders", "preloadUiShader"}, at = @At("TAIL"))
|
||||
public void onStartupShaders(CallbackInfo ci) {
|
||||
LOGGER.info("Starting up renderer");
|
||||
LOGGER.info("Starting up renderer (forge)");
|
||||
if (!DependencySetupDoneCheck.isDone) {
|
||||
LOGGER.warn("Dependency setup is not done yet, skipping renderer this startup event!");
|
||||
return;
|
||||
}
|
||||
ClientApi.INSTANCE.rendererStartupEvent();
|
||||
}
|
||||
#else
|
||||
|
||||
+16
@@ -25,10 +25,12 @@ import com.mojang.math.Matrix4f;
|
||||
#else
|
||||
import org.joml.Matrix4f;
|
||||
#endif
|
||||
import com.seibel.distanthorizons.common.rendering.SeamlessOverdraw;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
@@ -40,6 +42,8 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* This class is used to mix in my rendering code
|
||||
* before Minecraft starts rendering blocks.
|
||||
@@ -130,6 +134,18 @@ public class MixinLevelRenderer
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
|
||||
ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
|
||||
|
||||
// experimental proof-of-concept option
|
||||
if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get())
|
||||
{
|
||||
FloatBuffer modifiedMatrixBuffer = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(projectionMatrix, previousPartialTicks);
|
||||
|
||||
#if PRE_MC_1_19_4
|
||||
projectionMatrix.load(modifiedMatrixBuffer);
|
||||
#else
|
||||
projectionMatrix.set(modifiedMatrixBuffer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
|
||||
|
||||
@@ -6,6 +6,7 @@ org.gradle.caching=true
|
||||
# Mod Info
|
||||
mod_name=DistantHorizons
|
||||
mod_version=2.0.0-a-dev
|
||||
api_version=1.0.0
|
||||
maven_group=com.seibel.distanthorizons
|
||||
mod_readable_name=Distant Horizons
|
||||
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
|
||||
|
||||
@@ -45,3 +45,4 @@ forge_version=36.2.39
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=2
|
||||
enable_terrafirmacraft=0
|
||||
|
||||
@@ -45,3 +45,4 @@ forge_version=37.1.1
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
enable_terrafirmacraft=0
|
||||
|
||||
@@ -54,3 +54,4 @@ forge_version=40.2.9
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
enable_terrafirmacraft=0
|
||||
@@ -45,3 +45,4 @@ forge_version=43.2.14
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
enable_terrafirmacraft=0
|
||||
|
||||
@@ -45,3 +45,4 @@ forge_version=45.1.0
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
enable_terrafirmacraft=0
|
||||
|
||||
@@ -45,3 +45,4 @@ forge_version=47.0.1
|
||||
# 2 = Can be referenced in code and runs in client
|
||||
enable_starlight_forge=0
|
||||
enable_terraforged=0
|
||||
enable_terrafirmacraft=0
|
||||
|
||||
Reference in New Issue
Block a user