This commit is contained in:
s809
2023-07-23 11:09:07 +05:00
29 changed files with 374 additions and 313 deletions
+16 -27
View File
@@ -1,6 +1,6 @@
# use Eclipse's JDK
image: gradle:eclipse-temurin
# The ci should always use an unix/unix-like OS to work
# The ci should always use a unix(-like) OS to work
# all stages need to be defined here
@@ -14,18 +14,26 @@ stages:
- pages
variables:
# Pull core when building
GIT_SUBMODULE_STRATEGY: recursive
# Pull core when building
GIT_SUBMODULE_STRATEGY: recursive
# This can be extended so code is a bit less duplicated
# These can be extended so code is a bit less duplicated
.build_java:
image: eclipse-temurin:17
cache:
key: "gradleCache"
policy: pull-push
paths:
- .gradle
- cache/
allow_failure: true
.build_mc:
script:
# this both runs the unit tests and assembles the code
- ./gradlew clean -PmcVer="${MC_VER}" --gradle-user-home cache/;
- ./gradlew build -PmcVer="${MC_VER}" --gradle-user-home cache/;
- ./gradlew mergeJars -PmcVer="${MC_VER}" --gradle-user-home cache/;
image: eclipse-temurin:17
artifacts:
name: "NightlyBuild_${MC_VER}-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
paths:
@@ -43,13 +51,7 @@ variables:
- quilt/build/libs/*-sources.jar
expire_in: 1 day
when: always
cache:
key: "gradleCache"
policy: pull-push
paths:
- .gradle
- cache/
allow_failure: true
extends: .build_java
# 1.18.2 build
@@ -92,7 +94,6 @@ api:
# 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:
@@ -104,13 +105,7 @@ api:
- 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
extends: .build_java
# generate and publish API javadocs
@@ -124,17 +119,11 @@ pages:
- ./gradlew api:javadoc --gradle-user-home cache/;
- mkdir public
- cp -r $CI_PROJECT_DIR/coreSubProjects/api/build/docs/javadoc/. public
image: eclipse-temurin:17
artifacts:
paths:
- public
cache:
key: "gradleCache"
policy: pull-push
paths:
- .gradle
- cache/
allow_failure: false
extends: .build_java
+2 -2
View File
@@ -98,12 +98,12 @@ forgix {
jarLocation = "build/libs/DistantHorizons-forge-${rootProject.versionStr}.jar"
}
findProject(":fabric")
if (findProject(":fabric"))
fabric {
jarLocation = "build/libs/DistantHorizons-fabric-${rootProject.versionStr}.jar"
}
findProject(":quilt")
if (findProject(":quilt"))
quilt {
jarLocation = "build/libs/DistantHorizons-quilt-${rootProject.versionStr}.jar"
}
@@ -29,7 +29,7 @@ import com.mojang.math.Matrix4f;
import org.joml.Matrix4f;
#endif
import com.seibel.distanthorizons.core.enums.ELodDirection;
import com.seibel.distanthorizons.core.enums.EDhDirection;
import com.seibel.distanthorizons.core.pos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
@@ -89,12 +89,12 @@ public class McObjectConverter
static final Direction[] directions;
static final ELodDirection[] lodDirections;
static final EDhDirection[] lodDirections;
static {
ELodDirection[] lodDirs = ELodDirection.values();
EDhDirection[] lodDirs = EDhDirection.values();
directions = new Direction[lodDirs.length];
lodDirections = new ELodDirection[lodDirs.length];
for (ELodDirection lodDir : lodDirs)
lodDirections = new EDhDirection[lodDirs.length];
for (EDhDirection lodDir : lodDirs)
{
Direction dir;
switch (lodDir.name().toUpperCase())
@@ -138,11 +138,11 @@ public class McObjectConverter
return new ChunkPos(wrappedPos.x, wrappedPos.z);
}
public static Direction Convert(ELodDirection lodDirection)
public static Direction Convert(EDhDirection lodDirection)
{
return directions[lodDirection.ordinal()];
}
public static ELodDirection Convert(Direction direction)
public static EDhDirection Convert(Direction direction)
{
return lodDirections[direction.ordinal()];
}
@@ -103,7 +103,7 @@ public class BiomeWrapper implements IBiomeWrapper
}
catch (Exception e)
{
throw new IOException("Failed to deserialize biome wrapper", e);
throw new IOException("Failed to deserialize the string ["+str+"] into a BiomeWrapper: "+e.getMessage(), e);
}
}
@@ -3,7 +3,9 @@ package com.seibel.distanthorizons.common.wrappers.block;
import com.google.gson.JsonParser;
import com.mojang.serialization.JsonOps;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.util.ColorUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
import net.minecraft.client.resources.model.Material;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
@@ -18,62 +20,105 @@ public class BlockStateWrapper implements IBlockStateWrapper
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static final BlockStateWrapper AIR = new BlockStateWrapper(null);
public static ConcurrentHashMap<BlockState, BlockStateWrapper> cache = new ConcurrentHashMap<>();
//==============//
// constructors //
//==============//
public static BlockStateWrapper fromBlockState(BlockState blockState)
{
if (blockState == null || blockState.isAir())
return AIR;
{
return AIR;
}
if (blockState.getFluidState().isEmpty())
return cache.computeIfAbsent(blockState, BlockStateWrapper::new);
else
return cache.computeIfAbsent(blockState.getFluidState().createLegacyBlock(), BlockStateWrapper::new);
return cache.computeIfAbsent(blockState, BlockStateWrapper::new);
}
public final BlockState blockState;
BlockStateWrapper(BlockState blockState) {
BlockStateWrapper(BlockState blockState)
{
this.blockState = blockState;
//LOGGER.info("Created BlockStateWrapper for {}", blockState);
LOGGER.trace("Created BlockStateWrapper for ["+blockState+"]");
}
@Override
//=========//
// methods //
//=========//
@Override
public int getOpacity()
{
// this method isn't perfect, but works well enough for our use case
if (this.isAir() || !this.isSolid())
{
// completely transparent
return 0;
}
else
{
// completely opaque
return 16;
}
}
@Override
public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; }
@Override
public String serialize()
{
if (this.blockState == null)
{
return "AIR";
}
return BlockState.CODEC.encodeStart(JsonOps.COMPRESSED, this.blockState).get().orThrow().toString();
return BlockState.CODEC.encodeStart(JsonOps.INSTANCE, this.blockState).get().orThrow().toString();
}
public static BlockStateWrapper deserialize(String str) throws IOException {
if (str.equals("AIR")) {
return AIR;
}
try {
return new BlockStateWrapper(
BlockState.CODEC.decode(JsonOps.COMPRESSED, JsonParser.parseString(str)).get().orThrow().getFirst()
);
} catch (Exception e) {
throw new IOException("Failed to deserialize BlockStateWrapper", e);
}
public static BlockStateWrapper deserialize(String str) throws IOException
{
if (str.equals("AIR"))
{
return AIR;
}
try
{
return new BlockStateWrapper(
BlockState.CODEC.decode(JsonOps.INSTANCE, JsonParser.parseString(str)).get().orThrow().getFirst()
);
}
catch (Exception e)
{
throw new IOException("Failed to deserialize the string ["+str+"] into a BlockStateWrapper: "+e.getMessage(), e);
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BlockStateWrapper that = (BlockStateWrapper) o;
return Objects.equals(blockState, that.blockState);
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null || this.getClass() != obj.getClass())
{
return false;
}
BlockStateWrapper that = (BlockStateWrapper) obj;
return Objects.equals(this.blockState, that.blockState);
}
@Override
public int hashCode() {
return Objects.hash(blockState);
}
public int hashCode() { return Objects.hash(this.blockState); }
@Override
@@ -84,7 +129,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
public boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
@Override
public boolean isSolid() {
public boolean isSolid()
{
#if PRE_MC_1_20_1
return this.blockState.getMaterial().isSolid();
#else
@@ -93,7 +139,13 @@ public class BlockStateWrapper implements IBlockStateWrapper
}
@Override
public boolean isLiquid() {
public boolean isLiquid()
{
if (this.isAir())
{
return false;
}
#if PRE_MC_1_20_1
return this.blockState.getMaterial().isLiquid();
#else
@@ -101,6 +153,4 @@ public class BlockStateWrapper implements IBlockStateWrapper
#endif
}
}
@@ -22,11 +22,10 @@ package com.seibel.distanthorizons.common.wrappers.chunk;
import com.seibel.distanthorizons.api.enums.config.ELightGenerationMode;
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.pos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.core.pos.Pos2D;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
@@ -36,31 +35,31 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
#if POST_MC_1_17_1
import net.minecraft.core.QuartPos;
#endif
import net.minecraft.core.SectionPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.levelgen.Heightmap;
// Which nullable should be used???
import net.minecraft.world.level.lighting.LevelLightEngine;
#if POST_MC_1_20_1
import net.minecraft.world.level.lighting.LightEngine;
#endif
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.WeakHashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
#if POST_MC_1_17_1
import net.minecraft.core.QuartPos;
#endif
#if POST_MC_1_20_1
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.core.SectionPos;
#endif
public class ChunkWrapper implements IChunkWrapper
{
private final ChunkAccess chunk;
@@ -68,11 +67,14 @@ public class ChunkWrapper implements IChunkWrapper
private final LevelReader lightSource;
private final ILevelWrapper wrappedLevel;
private final boolean useMcLightingEngine;
private final boolean isDhGeneratedChunk;
private boolean isDhLightCorrect = false;
private final HashMap<DhBlockPos, Integer> blockLightAtRelBlockPos = new HashMap<>(LodUtil.CHUNK_WIDTH * LodUtil.CHUNK_WIDTH * 256);
private final HashMap<DhBlockPos, Integer> skyLightAtRelBlockPos = new HashMap<>(LodUtil.CHUNK_WIDTH * LodUtil.CHUNK_WIDTH * 256);
private LinkedList<DhBlockPos> blockLightPosList = null;
private final boolean useDhLightingEngine;
private final HashMap<BlockPos, BlockState> blockStateByBlockPosCache = new HashMap<>();
// Due to vanilla `isClientLightReady()` not designed to be used by non-render thread, that value may return 'true'
// just before the light engine is ticked, (right after all light changes is marked to the engine to be processed).
// To fix this, on client-only mode, we mixin-redirect the `isClientLightReady()` so that after the call, it will
@@ -84,7 +86,13 @@ public class ChunkWrapper implements IChunkWrapper
// (Also, thread safety done via a reader writer lock)
private final static WeakHashMap<ChunkAccess, Boolean> chunksToUpdateClientLightReady = new WeakHashMap<>();
private final static ReentrantReadWriteLock weakMapLock = new ReentrantReadWriteLock();
//=============//
// constructor //
//=============//
public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource, @Nullable ILevelWrapper wrappedLevel)
{
this.chunk = chunk;
@@ -92,15 +100,17 @@ public class ChunkWrapper implements IChunkWrapper
this.wrappedLevel = wrappedLevel;
this.chunkPos = new DhChunkPos(chunk.getPos().x, chunk.getPos().z);
this.useMcLightingEngine = (Config.Client.Advanced.WorldGenerator.lightingEngine.get() == ELightGenerationMode.MINECRAFT);
// TODO is this the best way to differentiate between when we are generating chunks and when MC gave us a chunk?
this.isDhGeneratedChunk = (this.lightSource.getClass() == LightedWorldGenRegion.class);
boolean isDhGeneratedChunk = (this.lightSource.getClass() == DhLitWorldGenRegion.class);
this.useDhLightingEngine = isDhGeneratedChunk && (Config.Client.Advanced.WorldGenerator.worldGenLightingEngine.get() == ELightGenerationMode.DISTANT_HORIZONS);
weakMapLock.writeLock().lock();
chunksToUpdateClientLightReady.put(chunk, false);
weakMapLock.writeLock().unlock();
}
//=========//
// methods //
//=========//
@@ -137,7 +147,7 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public IBiomeWrapper getBiome(int x, int y, int z)
public IBiomeWrapper getBiome(int relX, int relY, int relZ)
{
//if (wrappedLevel != null) return wrappedLevel.getBiome(new DhBlockPos(x + getMinX(), y, z + getMinZ()));
@@ -152,7 +162,7 @@ public class ChunkWrapper implements IChunkWrapper
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
#else //Now returns a Holder<Biome> instead of Biome
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
QuartPos.fromBlock(relX), QuartPos.fromBlock(relY), QuartPos.fromBlock(relZ)));
#endif
}
@@ -162,20 +172,29 @@ public class ChunkWrapper implements IChunkWrapper
public ChunkAccess getChunk() { return this.chunk; }
@Override
public int getMaxX() { return this.chunk.getPos().getMaxBlockX(); }
public int getMaxBlockX() { return this.chunk.getPos().getMaxBlockX(); }
@Override
public int getMaxZ() { return this.chunk.getPos().getMaxBlockZ(); }
public int getMaxBlockZ() { return this.chunk.getPos().getMaxBlockZ(); }
@Override
public int getMinX() { return this.chunk.getPos().getMinBlockX(); }
public int getMinBlockX() { return this.chunk.getPos().getMinBlockX(); }
@Override
public int getMinZ() { return this.chunk.getPos().getMinBlockZ(); }
public int getMinBlockZ() { return this.chunk.getPos().getMinBlockZ(); }
@Override
public long getLongChunkPos() { return this.chunk.getPos().toLong(); }
@Override
public void setIsDhLightCorrect(boolean isDhLightCorrect) { this.isDhLightCorrect = isDhLightCorrect; }
@Override
public boolean isLightCorrect()
{
if (this.useDhLightingEngine)
{
return this.isDhLightCorrect;
}
#if PRE_MC_1_18_2
return true;
#else
@@ -201,132 +220,101 @@ public class ChunkWrapper implements IChunkWrapper
#endif
}
@Override
public int getBlockLight(int x, int y, int z)
public int getDhBlockLight(int relX, int relY, int relZ)
{
// use the full lighting engine when the chunks are within render distance or the config requests it
if (this.useMcLightingEngine || !this.isDhGeneratedChunk)
{
// FIXME this returns 0 if the chunks unload
// MC lighting method
return this.lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x+this.getMinX(), y, z+this.getMinZ()));
}
else
{
// DH lighting method
return this.getMaxBlockLightAtBlockPos(new DhBlockPos(x, y, z));
}
throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
return this.blockLightAtRelBlockPos.getOrDefault(new DhBlockPos(relX, relY, relZ), 0);
}
/**
* Note: this doesn't take into account blocks outside this chunk's borders <br>
* AKA: there will be sharp shadow cut-offs on chunk boundaries
*
* @param inputPos a relative position for this chunk (IE between [0,0] and [15,15])
* @apiNote TODO DH lighting should be moved into its own class in Core
*/
private int getMaxBlockLightAtBlockPos(DhBlockPos inputPos)
@Override
public void setDhBlockLight(int relX, int relY, int relZ, int lightValue)
{
// how many blocks (in a square) to take into account when generating lighting
// higher numbers will make the lighting more accurate but will take significantly longer
int width = 4;
int maxBlockLight = this.getCachedBlockState(new BlockPos(inputPos.x, inputPos.y, inputPos.z)).getLightEmission();
int inputMaxYPos = this.getSolidHeightMapValue(inputPos.x, inputPos.z);
// min and max calls to clamp the position to this chunk
for (int relX = Math.max(0, inputPos.x-width); relX < Math.min(inputPos.x+width, LodUtil.CHUNK_WIDTH); relX++)
{
for (int relZ = Math.max(0, inputPos.z-width); relZ < Math.min(inputPos.z+width, LodUtil.CHUNK_WIDTH); relZ++)
{
int lightYPos = this.getSolidHeightMapValue(relX, relZ);
if (inputPos.y < lightYPos && inputPos.y < inputMaxYPos)
{
// input is below the light
// and another block that isn't the light, ignore
continue;
}
// the max(height, height-1) is to fix an edge case involving torches
int lightValue = Math.max(
this.getCachedBlockState(new BlockPos(relX, lightYPos, relZ)).getLightEmission(),
this.getCachedBlockState(new BlockPos(relX, lightYPos-1, relZ)).getLightEmission());
int centerDistanceFromLight = new Pos2D(inputPos.x, inputPos.z).manhattanDist(new Pos2D(relX, relZ));
// multiply falloff by 2 to make light fade faster to reduce the number of hard edges caused by going outside of chunk boundaries
// (This could be removed if we add the ability to access blocks outside this chunk)
centerDistanceFromLight *= 2;
lightValue = lightValue - centerDistanceFromLight;
maxBlockLight = Math.max(maxBlockLight, lightValue);
}
}
return maxBlockLight;
throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
this.blockLightAtRelBlockPos.put(new DhBlockPos(relX, relY, relZ), lightValue);
}
@Override
public int getSkyLight(int x, int y, int z)
public int getDhSkyLight(int relX, int relY, int relZ)
{
throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
return this.skyLightAtRelBlockPos.getOrDefault(new DhBlockPos(relX, relY, relZ), 0);
}
@Override
public void setDhSkyLight(int relX, int relY, int relZ, int lightValue)
{
throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
this.skyLightAtRelBlockPos.put(new DhBlockPos(relX, relY, relZ), lightValue);
}
@Override
public int getBlockLight(int relX, int relY, int relZ)
{
throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
// use the full lighting engine when the chunks are within render distance or the config requests it
if (this.useMcLightingEngine || !this.isDhGeneratedChunk)
if (this.useDhLightingEngine)
{
// FIXME this returns 0 if the chunks unload
// MC lighting method
return this.lightSource.getBrightness(LightLayer.SKY, new BlockPos(x+this.getMinX(), y, z+this.getMinZ()));
// DH lighting method
return this.blockLightAtRelBlockPos.getOrDefault(new DhBlockPos(relX, relY, relZ), 0);
}
else
{
// DH lighting method
return this.getMaxSkyLightAtBlockPos(new DhBlockPos(x,y,z));
// note: this returns 0 if the chunk is unload
// MC lighting method
return this.lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(relX +this.getMinBlockX(), relY, relZ +this.getMinBlockZ()));
}
}
/**
* Note: this doesn't take into account blocks outside this chunk's borders <br>
* AKA: there will be sharp shadow cut-offs on chunk boundaries
*
* @param inputPos a relative position for this chunk (IE between [0,0] and [15,15])
* @apiNote TODO DH lighting should be moved into its own class in Core
*/
private int getMaxSkyLightAtBlockPos(DhBlockPos inputPos)
{
// Note: this doesn't take into account blocks outside this chunk's borders
// AKA: there will be sharp shadow cut-offs on chunk boundaries
// how many blocks (in a square) to take into account when generating lighting
// higher numbers will make the lighting more accurate but will take longer
int width = 4;
int maxSkyLight = 0;
Pos2D centerPos = new Pos2D(inputPos.x,inputPos.z);
// min and max calls to clamp the position to this chunk
for (int relX = Math.max(0, inputPos.x-width); relX < Math.min(inputPos.x+width, LodUtil.CHUNK_WIDTH); relX++)
{
for (int relZ = Math.max(0, inputPos.z-width); relZ < Math.min(inputPos.z+width, LodUtil.CHUNK_WIDTH); relZ++)
{
int heightAtPos = this.getLightBlockingHeightMapValue(relX, relZ);
int lightAtRelPos = (inputPos.y >= heightAtPos) ? 15 : 0; // 15 if it can see the sky, 0 otherwise
int centerDistanceFromLight = centerPos.manhattanDist(new Pos2D(relX, relZ));
int centerLight = Math.max(0, lightAtRelPos - centerDistanceFromLight);
maxSkyLight = Math.max(maxSkyLight, centerLight);
}
}
return maxSkyLight;
}
@Override
public boolean doesNearbyChunksExist()
public int getSkyLight(int relX, int relY, int relZ)
{
if (this.lightSource instanceof LightedWorldGenRegion)
throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
// use the full lighting engine when the chunks are within render distance or the config requests it
if (this.useDhLightingEngine)
{
// DH lighting method
return this.skyLightAtRelBlockPos.getOrDefault(new DhBlockPos(relX, relY, relZ), 0);
}
else
{
// MC lighting method
return this.lightSource.getBrightness(LightLayer.SKY, new BlockPos(relX +this.getMinBlockX(), relY, relZ +this.getMinBlockZ()));
}
}
@Override
public List<DhBlockPos> getBlockLightPosList()
{
// only populate the list once
if (this.blockLightPosList == null)
{
this.blockLightPosList = new LinkedList<>();
#if PRE_MC_1_20_1
this.chunk.getLights().forEach((blockPos) ->
{
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
});
#elif MC_1_20_1
this.chunk.findBlockLightSources((blockPos, blockState) ->
{
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
});
#endif
}
return this.blockLightPosList;
}
@Override
public boolean doNearbyChunksExist()
{
if (this.lightSource instanceof DhLitWorldGenRegion)
{
return true;
}
@@ -355,10 +343,10 @@ public class ChunkWrapper implements IChunkWrapper
public String toString() { return this.chunk.getClass().getSimpleName() + this.chunk.getPos(); }
@Override
public IBlockStateWrapper getBlockState(int x, int y, int z)
public IBlockStateWrapper getBlockState(int relX, int relY, int relZ)
{
//if (wrappedLevel != null) return wrappedLevel.getBlockState(new DhBlockPos(x + getMinX(), y, z + getMinZ()));
return BlockStateWrapper.fromBlockState(this.chunk.getBlockState(new BlockPos(x,y,z)));
return BlockStateWrapper.fromBlockState(this.chunk.getBlockState(new BlockPos(relX, relY, relZ)));
}
@Override
@@ -412,23 +400,21 @@ public class ChunkWrapper implements IChunkWrapper
}
#endif
}
//================//
// helper methods //
//================//
/** can be used to speed up operations that need to interact with blockstates often */
private BlockState getCachedBlockState(BlockPos pos)
/** used to prevent accidentally attempting to get/set values outside this chunk's boundaries */
private static void throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(int x, int y, int z) throws IndexOutOfBoundsException
{
if (!this.blockStateByBlockPosCache.containsKey(pos))
if (x < 0 || x >= LodUtil.CHUNK_WIDTH
|| z < 0 || z >= LodUtil.CHUNK_WIDTH)
{
BlockState blockState = this.chunk.getBlockState(pos);
this.blockStateByBlockPosCache.put(pos, blockState);
throw new IndexOutOfBoundsException("Indices are relative and must be between 0 and 15 (inclusive), X:"+x+", Y:"+y+" Z:"+z);
}
return this.blockStateByBlockPosCache.get(pos);
}
}
@@ -28,8 +28,8 @@ import com.mojang.blaze3d.platform.NativeImage;
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
import com.seibel.distanthorizons.core.enums.EDhDirection;
import com.seibel.distanthorizons.coreapi.ModInfo;
import com.seibel.distanthorizons.core.enums.ELodDirection;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
@@ -108,7 +108,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
//=================//
@Override
public float getShade(ELodDirection lodDirection) {
public float getShade(EDhDirection lodDirection) {
if (mc.level != null)
{
Direction mcDir = McObjectConverter.Convert(lodDirection);
@@ -86,16 +86,13 @@ public class ServerLevelWrapper implements IServerLevelWrapper
@Override
public IClientLevelWrapper tryGetClientLevelWrapper()
{
try
MinecraftClientWrapper client = MinecraftClientWrapper.INSTANCE;
if (client.mc.level == null)
{
MinecraftClientWrapper client = MinecraftClientWrapper.INSTANCE;
return ClientLevelWrapper.getWrapper(client.mc.level);
}
catch (Exception e)
{
LOGGER.error("Failed to get client side wrapper for server level "+level+".");
return null;
}
return ClientLevelWrapper.getWrapper(client.mc.level);
}
@Override
@@ -26,6 +26,7 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGeneratio
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.*;
import com.seibel.distanthorizons.core.dataObjects.transformers.FullDataToRenderDataTransformer;
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
import com.seibel.distanthorizons.core.level.IDhServerLevel;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.api.enums.config.ELightGenerationMode;
@@ -38,6 +39,7 @@ import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
import com.seibel.distanthorizons.core.util.objects.DhThreadFactory;
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvironmentWrapper;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import java.io.IOException;
import java.util.*;
@@ -48,7 +50,6 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepBiomes;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepFeatures;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepLight;
@@ -59,6 +60,8 @@ import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepSurfa
#if POST_MC_1_19_4
import net.minecraft.core.registries.Registries;
#else
import net.minecraft.core.Registry;
#endif
import net.minecraft.server.level.ServerLevel;
@@ -73,7 +76,6 @@ import net.minecraft.world.level.chunk.storage.RegionFileStorage;
import net.minecraft.world.level.levelgen.DebugLevelSource;
import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import org.apache.logging.log4j.LogManager;
@@ -156,7 +158,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
}
public static final int TIMEOUT_SECONDS = 60;
private final IDhServerLevel serverlevel;
//=================Generation Step===================
@@ -250,8 +252,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
public BatchGenerationEnvironment(IDhServerLevel serverlevel)
{
super(serverlevel);
this.serverlevel = serverlevel;
EVENT_LOGGER.info("================WORLD_GEN_STEP_INITING=============");
serverlevel.getServerLevelWrapper().getDimensionType();
ChunkGenerator generator = ((ServerLevelWrapper) (serverlevel.getServerLevelWrapper())).getLevel().getChunkSource().getGenerator();
if (!(generator instanceof NoiseBasedChunkGenerator ||
generator instanceof DebugLevelSource ||
@@ -327,7 +333,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
iter.remove();
}
else if (event.hasTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS))
else if (event.hasTimeout(Config.Client.Advanced.WorldGenerator.worldGenerationTimeoutLengthInSeconds.get(), TimeUnit.SECONDS))
{
EVENT_LOGGER.error("Batching World Generator: " + event + " timed out and terminated!");
EVENT_LOGGER.info("Dump PrefEvent: " + event.timer);
@@ -404,11 +410,11 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
}
private static ArrayGridList<ChunkAccess> GetCutoutFrom(ArrayGridList<ChunkAccess> total, int border) {
private static <T> ArrayGridList<T> GetCutoutFrom(ArrayGridList<T> total, int border) {
return new ArrayGridList<>(total, border, total.gridSize - border);
}
private static ArrayGridList<ChunkAccess> GetCutoutFrom(ArrayGridList<ChunkAccess> total, EDhApiWorldGenerationStep step) {
private static <T> ArrayGridList<T> GetCutoutFrom(ArrayGridList<T> total, EDhApiWorldGenerationStep step) {
return GetCutoutFrom(total, MaxBorderNeeded - BorderNeeded.get(step));
}
@@ -416,9 +422,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
EVENT_LOGGER.debug("Lod Generate Event: "+genEvent.minPos);
ArrayGridList<ChunkAccess> totalChunks;
ArrayGridList<ChunkAccess> finalGenChunks;
LightedWorldGenRegion region;
ArrayGridList<ChunkWrapper> chunkWrapperList;
DhLitWorldGenRegion region;
WorldGenLevelLightEngine lightEngine;
LightGetterAdaptor adaptor;
@@ -429,6 +434,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
try
{
ArrayGridList<ChunkAccess> totalChunks;
adaptor = new LightGetterAdaptor(params.level);
lightEngine = new WorldGenLevelLightEngine(adaptor);
@@ -458,11 +465,23 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
totalChunks = new ArrayGridList<>(refSize, (x,z) -> generator.generate(x + refPosX,z + refPosZ));
genEvent.refreshTimeout();
region = new LightedWorldGenRegion(params.level, lightEngine, totalChunks,
region = new DhLitWorldGenRegion(params.level, lightEngine, totalChunks,
ChunkStatus.STRUCTURE_STARTS, refSize/2, generator);
adaptor.setRegion(region);
genEvent.threadedParam.makeStructFeat(region, params);
this.generateDirect(genEvent, totalChunks, borderSize, genEvent.targetGenerationStep, region);
chunkWrapperList = new ArrayGridList<>(totalChunks.gridSize);
totalChunks.forEachPos((x, z) ->
{
ChunkAccess chunk = totalChunks.get(x, z);
if (chunk != null)
{
chunkWrapperList.set(x,z, new ChunkWrapper(chunk, region, null));
}
});
this.generateDirect(genEvent, chunkWrapperList, borderSize, genEvent.targetGenerationStep, region);
genEvent.timer.nextEvent("cleanup");
}
catch (StepStructureStart.StructStartCorruptedException f)
@@ -470,17 +489,19 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
genEvent.threadedParam.markAsInvalid();
throw (RuntimeException)f.getCause();
}
finalGenChunks = GetCutoutFrom(totalChunks, borderSize);
ArrayGridList<ChunkWrapper> finalGenChunks = GetCutoutFrom(chunkWrapperList, borderSize);
for (int offsetY = 0; offsetY < finalGenChunks.gridSize; offsetY++)
{
for (int offsetX = 0; offsetX < finalGenChunks.gridSize; offsetX++)
{
ChunkAccess target = finalGenChunks.get(offsetX, offsetY);
ChunkWrapper wrappedChunk = new ChunkWrapper(target, region, null);
if (target instanceof LevelChunk) {
ChunkWrapper wrappedChunk = finalGenChunks.get(offsetX, offsetY);
ChunkAccess target = wrappedChunk.getChunk();
if (target instanceof LevelChunk)
{
((LevelChunk) target).loaded = true;
}
if (!wrappedChunk.isLightCorrect())
{
throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false");
@@ -526,8 +547,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
}
public void generateDirect(GenerationEvent genEvent, ArrayGridList<ChunkAccess> chunksToGenerate, int border,
EDhApiWorldGenerationStep step, LightedWorldGenRegion region) throws InterruptedException
public void generateDirect(GenerationEvent genEvent, ArrayGridList<ChunkWrapper> chunksToGenerate, int border,
EDhApiWorldGenerationStep step, DhLitWorldGenRegion region) throws InterruptedException
{
if (Thread.interrupted())
{
@@ -536,8 +557,9 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
try
{
chunksToGenerate.forEach((chunk) ->
chunksToGenerate.forEach((chunkWrapper) ->
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (chunk instanceof ProtoChunk)
{
ProtoChunk protoChunk = ((ProtoChunk) chunk);
@@ -613,7 +635,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
genEvent.timer.nextEvent("light");
boolean useMinecraftLightingEngine = Config.Client.Advanced.WorldGenerator.lightingEngine.get() == ELightGenerationMode.MINECRAFT;
boolean useMinecraftLightingEngine = Config.Client.Advanced.WorldGenerator.worldGenLightingEngine.get() == ELightGenerationMode.MINECRAFT;
if (useMinecraftLightingEngine)
{
// generates chunk lighting using MC's methods
@@ -625,29 +647,25 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
else
{
// ignores lighting
// generates lighting using DH's methods
chunksToGenerate.forEach((chunk) ->
int maxSkyLight = this.serverlevel.getServerLevelWrapper().hasSkyLight() ? 15 : 0;
// explicit cast required because java generics or something
ArrayList<IChunkWrapper> iChunkWrapperList = new ArrayList<>(chunksToGenerate);
for (int i = 0; i < iChunkWrapperList.size(); i++)
{
if (chunk instanceof ProtoChunk)
IChunkWrapper centerChunk = iChunkWrapperList.get(i);
if (centerChunk == null)
{
chunk.setLightCorrect(true); // TODO why are we checking instanceof ProtoChunk?
// TODO: This is due to old times where it may return actual live chunks, which is LevelChunk.
// that though is no longer needed...
continue;
}
DhLightingEngine.INSTANCE.lightChunks(centerChunk, iChunkWrapperList, maxSkyLight);
centerChunk.setIsDhLightCorrect(true);
}
#if POST_MC_1_18_2
if (chunk instanceof LevelChunk)
{
LevelChunk levelChunk = (LevelChunk) chunk;
levelChunk.setLightCorrect(true);
#if PRE_MC_1_20_1
levelChunk.setClientLightReady(true);
#endif
levelChunk.loaded = true;
}
#endif
});
}
genEvent.refreshTimeout();
@@ -54,7 +54,7 @@ import net.minecraft.world.level.chunk.ImposterProtoChunk;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.lighting.LevelLightEngine;
public class LightedWorldGenRegion extends WorldGenRegion
public class DhLitWorldGenRegion extends WorldGenRegion
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
@@ -87,7 +87,7 @@ public class LightedWorldGenRegion extends WorldGenRegion
#endif
#endif
public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine,
public DhLitWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine,
List<ChunkAccess> chunkList, ChunkStatus chunkStatus, int writeRadius,
BatchGenerationEnvironment.EmptyChunkGenerator generator)
{
@@ -34,7 +34,7 @@ import net.minecraft.world.level.chunk.LightChunk;
public class LightGetterAdaptor implements LightChunkGetter {
private final BlockGetter heightGetter;
public LightedWorldGenRegion genRegion = null;
public DhLitWorldGenRegion genRegion = null;
final boolean shouldReturnNull;
public LightGetterAdaptor(BlockGetter heightAccessor) {
@@ -42,7 +42,7 @@ public class LightGetterAdaptor implements LightChunkGetter {
shouldReturnNull = ModAccessorInjector.INSTANCE.get(IStarlightAccessor.class) != null;
}
public void setRegion(LightedWorldGenRegion region) {
public void setRegion(DhLitWorldGenRegion region) {
genRegion = region;
}
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
import java.util.ArrayList;
import java.util.List;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
@@ -52,11 +53,13 @@ public final class StepBiomes {
public final ChunkStatus STATUS = ChunkStatus.BIOMES;
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks) {
List<ChunkWrapper> chunkWrappers) {
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
for (ChunkAccess chunk : chunks) {
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (chunk.getStatus().isOrAfter(STATUS)) continue;
((ProtoChunk) chunk).setStatus(STATUS);
chunksToDo.add(chunk);
@@ -21,9 +21,10 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
import java.util.ArrayList;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
import net.minecraft.ReportedException;
@@ -50,11 +51,13 @@ public final class StepFeatures {
public final ChunkStatus STATUS = ChunkStatus.FEATURES;
public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion,
ArrayGridList<ChunkAccess> chunks) {
public void generateGroup(ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
ArrayGridList<ChunkWrapper> chunkWrappers) {
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
for (ChunkAccess chunk : chunks) {
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (chunk.getStatus().isOrAfter(STATUS)) continue;
((ProtoChunk) chunk).setStatus(STATUS);
chunksToDo.add(chunk);
@@ -19,6 +19,7 @@
package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.WorldGenLevelLightEngine;
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
@@ -49,14 +50,18 @@ public final class StepLight {
public void generateGroup(
#if PRE_MC_1_17_1 LevelLightEngine lightEngine,
#else LightEventListener lightEngine, #endif
ArrayGridList<ChunkAccess> chunks) {
ArrayGridList<ChunkWrapper> chunkWrappers) {
for (ChunkAccess chunk : chunks) {
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (chunk.getStatus().isOrAfter(STATUS)) continue;
((ProtoChunk) chunk).setStatus(STATUS);
}
for (ChunkAccess chunk : chunks) {
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
boolean hasCorrectBlockLight = (chunk instanceof LevelChunk && chunk.isLightCorrect());
try {
if (lightEngine == null) {
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
import java.util.ArrayList;
import java.util.List;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
@@ -55,11 +56,13 @@ public final class StepNoise {
public final ChunkStatus STATUS = ChunkStatus.NOISE;
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks) {
List<ChunkWrapper> chunkWrappers) {
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
for (ChunkAccess chunk : chunks) {
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (chunk.getStatus().isOrAfter(STATUS)) continue;
((ProtoChunk) chunk).setStatus(STATUS);
chunksToDo.add(chunk);
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
import java.util.ArrayList;
import java.util.List;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
@@ -49,11 +50,13 @@ public final class StepStructureReference {
public final ChunkStatus STATUS = ChunkStatus.STRUCTURE_REFERENCES;
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks) {
List<ChunkWrapper> chunkWrappers) {
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
for (ChunkAccess chunk : chunks) {
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (chunk.getStatus().isOrAfter(STATUS)) continue;
((ProtoChunk) chunk).setStatus(STATUS);
chunksToDo.add(chunk);
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
import java.util.ArrayList;
import java.util.List;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
@@ -59,12 +60,13 @@ public final class StepStructureStart
}
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks)
List<ChunkWrapper> chunkWrappers)
{
ArrayList<ChunkAccess> chunksToDo = new ArrayList<>();
for (ChunkAccess chunk : chunks)
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (!chunk.getStatus().isOrAfter(STATUS))
{
((ProtoChunk) chunk).setStatus(STATUS);
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
import java.util.ArrayList;
import java.util.List;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
@@ -47,10 +48,12 @@ public final class StepSurface {
public final ChunkStatus STATUS = ChunkStatus.SURFACE;
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks) {
List<ChunkWrapper> chunkWrappers) {
ArrayList<ChunkAccess> chunksToDo = new ArrayList<>();
for (ChunkAccess chunk : chunks) {
for (ChunkWrapper chunkWrapper : chunkWrappers)
{
ChunkAccess chunk = chunkWrapper.getChunk();
if (chunk.getStatus().isOrAfter(STATUS)) continue;
((ProtoChunk) chunk).setStatus(STATUS);
chunksToDo.add(chunk);
@@ -84,11 +84,9 @@ public class FabricMain
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("optifine")) {
ModAccessorInjector.INSTANCE.bind(IOptifineAccessor.class, new OptifineAccessor());
}
/* #if POST_MC_1_17_1
if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("bclib")) {
ModAccessorInjector.INSTANCE.bind(IBCLibAccessor.class, new BCLibAccessor());
}
#endif*/
LOGGER.info(ModInfo.READABLE_NAME + " Initialized");
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null);
@@ -1,19 +1,19 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU GPL v3 License.
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 General Public License for more details.
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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/>.
*/
@@ -1,9 +1,13 @@
package com.seibel.distanthorizons.fabric.wrappers.modAccessor;
#if POST_MC_1_17_1 && FALSE
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IBCLibAccessor;
#if PRE_MC_1_19_2
import ru.bclib.config.ClientConfig;
import ru.bclib.config.Configs;
#else
import org.betterx.bclib.config.ClientConfig;
import org.betterx.bclib.config.Configs;
#endif
public class BCLibAccessor implements IBCLibAccessor {
@Override
@@ -16,5 +20,4 @@ public class BCLibAccessor implements IBCLibAccessor {
// This disabled fog from rendering within bclib
Configs.CLIENT_CONFIG.set(ClientConfig.CUSTOM_FOG_RENDERING, newValue);
}
}
#endif
}
@@ -50,7 +50,7 @@ public class MixinFogRenderer {
@Inject(at = @At("RETURN"),
method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZF)V",
remap = #if MC_1_16_5 true #else false #endif) // Remap messiness due to this being added by forge.
remap = #if MC_1_16_5 || POST_AND_MC_1_19_2 true #else false #endif) // Remap messiness due to this being added by forge.
private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, float partTick, CallbackInfo callback)
{
#if PRE_MC_1_17_1
@@ -12,11 +12,10 @@ import org.spongepowered.asm.mixin.injection.Redirect;
*
* @author coolGi
*/
#if PRE_MC_1_20_1 // FIXME: Forge seems to be missing the mapping for this ,and remap=false doesn't work... Help
@Mixin(TextureUtil.class)
public class MixinTextureUtil {
@Redirect(method = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;IIII)V",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texParameter(IIF)V", remap=false))
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_texParameter(IIF)V"), remap=false)
private static void setLodBias(int target, int pname, float param)
{
float biasValue = Config.Client.Advanced.Graphics.AdvancedGraphics.lodBias.get().floatValue();
@@ -26,5 +25,4 @@ public class MixinTextureUtil {
GlStateManager._texParameter(target, pname, biasValue);
}
}
}
#endif
}
+1 -1
View File
@@ -35,4 +35,4 @@ versionStr=
# This defines what MC version Intellij will use for the preprocessor
# and what version is used automatically by build and run commands
mcVer=1.18.2
mcVer=1.18.4
+1 -1
View File
@@ -17,7 +17,7 @@ fabric_api_version=0.76.0+1.18.2
lithium_version=mc1.18.2-0.10.3
sodium_version=mc1.18.2-0.4.1
iris_version=1.18.x-v1.6.4
bclib_version=1.4.5
bclib_version=1.4.6
immersive_portals_version=v1.4.11-1.18
canvas_version=mc118:1.0.2616
+1 -1
View File
@@ -16,7 +16,7 @@ fabric_api_version=0.76.0+1.19.2
lithium_version=
sodium_version=mc1.19.2-0.4.4
iris_version=1.6.4+1.19.2
bclib_version=1.4.5
bclib_version=2.1.6
immersive_portals_version=
canvas_version=mc119-1.0.2480
+3 -3
View File
@@ -1,7 +1,7 @@
# 1.19.4 version
java_version=17
minecraft_version=1.19.4
parchment_version=1.19.3:2023.03.12
parchment_version=1.19.3:2023.06.25
compatible_minecraft_versions=["1.19.4"]
accessWidenerVersion=1_19_4
builds_for=fabric,forge
@@ -16,7 +16,7 @@ fabric_api_version=0.83.0+1.19.4
lithium_version=
sodium_version=mc1.19.4-0.4.10
iris_version=1.6.4+1.19.4
bclib_version=
bclib_version=2.3.3
immersive_portals_version=
canvas_version=
@@ -29,7 +29,7 @@ fabric_api_version=0.83.0+1.19.4
enable_sodium=1
enable_lithium=0
enable_iris=0
enable_bclib=0
enable_bclib=1
enable_immersive_portals=0
enable_canvas=0
+3 -3
View File
@@ -1,7 +1,7 @@
# 1.20.1 version
java_version=17
minecraft_version=1.20.1
parchment_version=1.19.3:2023.03.12
parchment_version=1.19.3:2023.06.25
compatible_minecraft_versions=["1.20", "1.20.1"]
accessWidenerVersion=1_20
builds_for=fabric,forge
@@ -16,7 +16,7 @@ fabric_api_version=0.85.0+1.20.1
lithium_version=
sodium_version=mc1.20-0.4.10
iris_version=1.6.4+1.20.1
bclib_version=
bclib_version=3.0.11
immersive_portals_version=
canvas_version=
@@ -29,7 +29,7 @@ fabric_api_version=0.85.0+1.20.1
enable_sodium=1
enable_lithium=0
enable_iris=0
enable_bclib=0
enable_bclib=1
enable_immersive_portals=0
enable_canvas=0