This commit is contained in:
s809
2023-11-03 21:23:37 +05:00
31 changed files with 371 additions and 164 deletions
+3 -3
View File
@@ -33,9 +33,9 @@ build:
- MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2"]
script:
# this both runs the unit tests and assembles the code
- ./gradlew clean -PmcVer="${MC_VER}" -PgitMainBranch="${CI_COMMIT_BRANCH}" -PgitMainCommit="${CI_COMMIT_SHA}" -PgitCoreCommit="Unavailable (built by Gitlab CI)" --gradle-user-home cache/;
- ./gradlew build -PmcVer="${MC_VER}" -PgitMainBranch="${CI_COMMIT_BRANCH}" -PgitMainCommit="${CI_COMMIT_SHA}" -PgitCoreCommit="Unavailable (built by Gitlab CI)" --gradle-user-home cache/;
- ./gradlew mergeJars -PmcVer="${MC_VER}" -PgitMainBranch="${CI_COMMIT_BRANCH}" -PgitMainCommit="${CI_COMMIT_SHA}" -PgitCoreCommit="Unavailable (built by Gitlab CI)" --gradle-user-home cache/;
- ./gradlew clean -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/;
- ./gradlew build -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/;
- ./gradlew mergeJars -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/;
artifacts:
name: "NightlyBuild_${MC_VER}-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
paths:
+19 -19
View File
@@ -21,49 +21,49 @@ If you want to see a quick demo, check out a video covering the mod here:
### This branch supports the following versions of Minecraft:
#### 1.20.2
Fabric: 0.14.22\
Fabric API: 0.89.2+1.20.2\
Fabric: 0.14.24\
Fabric API: 0.90.4+1.20.2\
Forge: 48.0.13\
Parchment: 1.19.3:2023.03.25\
Parchment: 1.20.1:2023.09.03\
Modmenu: 8.0.0
#### 1.20.1, 1.20 (Default)
Fabric: 0.14.21\
Fabric API: 0.85.0+1.20.1\
Forge: 45.1.0\
Parchment: 1.19.3:2023.03.25\
Modmenu: 7.0.1
Fabric: 0.14.24\
Fabric API: 0.90.4+1.20.1\
Forge: 47.2.1\
Parchment: 1.20.1:2023.09.03\
Modmenu: 7.2.2
#### 1.19.4
Fabric: 0.14.21\
Fabric API: 0.83.0+1.19.4\
Forge: 45.1.0\
Parchment: 1.19.3:2023.06.25\
Modmenu: 6.2.3
Fabric: 0.14.24\
Fabric API: 0.87.1+1.19.4\
Forge: 45.2.4\
Parchment: 1.19.4:2023.06.26\
Modmenu: 6.3.1
#### 1.19.2
Fabric: 0.14.21\
Fabric API: 0.76.0+1.19.2\
Forge: 43.2.14\
Fabric: 0.14.24\
Fabric API: 0.76.1+1.19.2\
Forge: 43.3.2\
Parchment: 1.19.2:2022.11.27\
Modmenu: 4.2.0-beta.2
#### 1.18.2
Fabric: 0.14.21\
Fabric: 0.14.24\
Fabric API: 0.76.0+1.18.2\
Forge: 40.2.10\
Parchment: 1.18.2:2022.11.06\
Modmenu: 3.2.5
#### 1.17.1, 1.17
Fabric: 0.14.21\
Fabric: 0.14.24\
Fabric API: 0.46.1+1.17\
Forge: 37.1.1\
Parchment: 1.17.1:2021.12.12\
Modmenu: 2.0.14
#### 1.16.5, 1.16.4
Fabric: 0.14.21\
Fabric: 0.14.24\
Fabric API: 0.42.0+1.16\
Forge: 36.2.39\
Parchment: 1.16.5:2022.03.06\
+9 -22
View File
@@ -359,28 +359,15 @@ subprojects { p ->
// TODOI: Find something we can use so we can basically re-map only when the jar is shadowed and relocated
// println p.tasks.findByName('shadowJar')
// Gets git info for the project
def git_main_commit = "Git_not_found"
def git_core_commit = "Git_not_found"
def git_main_branch = "Git_not_found"
// These "hasProperty"'s are so that they can be passed through the cli (ie in the CI)
try {
// "git rev-parse --is-inside-work-tree".execute() // If git doesnt exist, or this isnt cloned from git, then this wont work
if (gitMainCommit != "null")
git_main_commit = gitMainCommit
else
git_main_commit = 'git rev-parse --verify HEAD'.execute().text.trim()
if (gitCoreCommit != "null")
git_core_commit = gitCoreCommit
else
git_core_commit = 'git ls-tree --object-only HEAD ../coreSubProjects'.execute().text.trim() // TODO: is there a way to do this universally
if (gitMainBranch != "null")
git_main_branch = gitMainBranch
else
git_main_branch = 'git symbolic-ref --short HEAD'.execute().text.trim()
if (infoGitCommit == "null")
infoGitCommit = 'git rev-parse --verify HEAD'.execute().text.trim()
if (infoGitBranch == "null")
infoGitBranch = 'git symbolic-ref --short HEAD'.execute().text.trim()
} catch (Exception e) {
infoGitCommit = infoGitBranch = "Git not found"
println "Git or Git project not found"
}
@@ -400,9 +387,9 @@ subprojects { p ->
java_version : java_version,
quilt_contributors : "{"+quilt_contributors.join(", ")+"}",
git_main_commit : git_main_commit,
git_core_commit : git_core_commit,
git_main_branch : git_main_branch,
info_git_commit : infoGitBranch,
info_git_branch : infoGitCommit,
info_build_source : infoBuildSource,
fabric_incompatibility_list : fabric_incompatibility_list,
fabric_recommend_list : fabric_recommend_list,
@@ -46,8 +46,8 @@ import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.logging.log4j.Logger;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
/**
* @version 2022-9-16
@@ -57,18 +57,21 @@ public class ClientBlockStateCache
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private static final HashSet<BlockState> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>();
private static final HashSet<BlockState> BROKEN_BLOCK_STATES = new HashSet<>();
#if PRE_MC_1_19_2
public static final Random random = new Random(0);
#else
public static final RandomSource random = RandomSource.create();
#endif
public final BlockState state;
public final BlockState blockState;
public final LevelReader level;
public final BlockPos pos;
public ClientBlockStateCache(BlockState blockState, IClientLevelWrapper samplingLevel, DhBlockPos samplingPos)
{
state = blockState;
this.blockState = blockState;
level = (LevelReader) samplingLevel.getWrappedMcObject();
pos = McObjectConverter.Convert(samplingPos);
resolveColors();
@@ -186,21 +189,21 @@ public class ClientBlockStateCache
private void resolveColors()
{
if (isColorResolved) return;
if (state.getFluidState().isEmpty())
if (blockState.getFluidState().isEmpty())
{
List<BakedQuad> quads = null;
for (Direction direction : DIRECTION_ORDER)
{
quads = Minecraft.getInstance().getModelManager().getBlockModelShaper().
getBlockModel(state).getQuads(state, direction, random);
getBlockModel(blockState).getQuads(blockState, direction, random);
if (quads != null && !quads.isEmpty() &&
!(state.getBlock() instanceof RotatedPillarBlock && direction == Direction.UP))
!(blockState.getBlock() instanceof RotatedPillarBlock && direction == Direction.UP))
break;
} ;
if (quads == null || quads.isEmpty())
{
quads = Minecraft.getInstance().getModelManager().getBlockModelShaper().
getBlockModel(state).getQuads(state, null, random);
getBlockModel(blockState).getQuads(blockState, null, random);
}
if (quads != null && !quads.isEmpty())
{
@@ -210,15 +213,15 @@ public class ClientBlockStateCache
baseColor = calculateColorFromTexture(
#if PRE_MC_1_17_1 quads.get(0).sprite,
#else quads.get(0).getSprite(), #endif
ColorMode.getColorMode(state.getBlock()));
ColorMode.getColorMode(blockState.getBlock()));
}
else
{ // Backup method.
needPostTinting = false;
needShade = false;
tintIndex = 0;
baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(state),
ColorMode.getColorMode(state.getBlock()));
baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(blockState),
ColorMode.getColorMode(blockState.getBlock()));
}
}
else
@@ -226,8 +229,8 @@ public class ClientBlockStateCache
needPostTinting = true;
needShade = false;
tintIndex = 0;
baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(state),
ColorMode.getColorMode(state.getBlock()));
baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(blockState),
ColorMode.getColorMode(blockState.getBlock()));
}
isColorResolved = true;
}
@@ -235,11 +238,70 @@ public class ClientBlockStateCache
public int getAndResolveFaceColor(BiomeWrapper biome, DhBlockPos pos)
{
// FIXME: impl per-face colors
if (!needPostTinting) return baseColor;
int tintColor = Minecraft.getInstance().getBlockColors()
.getColor(state, new TintWithoutLevelOverrider(biome), McObjectConverter.Convert(pos), tintIndex);
if (tintColor == -1) return baseColor;
return ColorUtil.multiplyARGBwithRGB(baseColor, tintColor);
// only get the tint if the block needs to be tinted
if (!this.needPostTinting)
{
return this.baseColor;
}
// don't try tinting blocks that don't support our method of tint getting
if (BROKEN_BLOCK_STATES.contains(this.blockState))
{
return this.baseColor;
}
// attempt to get the tint
int tintColor = -1;
try
{
// try to use the fast tint getter logic first
if (!BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
{
try
{
tintColor = Minecraft.getInstance().getBlockColors()
.getColor(this.blockState, new TintWithoutLevelOverrider(biome), McObjectConverter.Convert(pos), this.tintIndex);
}
catch (UnsupportedOperationException e)
{
// this exception generally occurs if the tint requires other blocks besides itself
LOGGER.debug("Unable to use ["+TintWithoutLevelOverrider.class.getSimpleName()+"] to get the block tint for block: [" + this.blockState + "] and biome: [" + biome + "] at pos: " + pos + ". Error: [" + e.getMessage() + "]. Attempting to use backup method...", e);
BLOCK_STATES_THAT_NEED_LEVEL.add(this.blockState);
}
}
// use the level logic only if requested
if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
{
// this logic can't be used all the time due to it breaking some blocks tinting
// specifically oceans don't render correctly
tintColor = Minecraft.getInstance().getBlockColors()
.getColor(this.blockState, new TintGetterOverrideFast(this.level), McObjectConverter.Convert(pos), this.tintIndex);
}
}
catch (Exception e)
{
// only display the error once per block/biome type to reduce log spam
if (!BROKEN_BLOCK_STATES.contains(this.blockState))
{
LOGGER.warn("Failed to get block color for block: [" + this.blockState + "] and biome: [" + biome + "] at pos: " + pos + ". Error: ["+e.getMessage() + "]. Note: future errors for this block/biome will be ignored.", e);
BROKEN_BLOCK_STATES.add(this.blockState);
}
}
if (tintColor != -1)
{
return ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor);
}
else
{
// unable to get the tinted color, use the base color instead
return this.baseColor;
}
}
}
@@ -263,10 +263,8 @@ public class ChunkWrapper implements IChunkWrapper
}
#if PRE_MC_1_17_1
return true;
#elif MC_1_17_1
return false; // MC's lighting engine never works for 1.17
#if MC_1_16_5 || MC_1_17_1
return false; // MC's lighting engine doesn't work consistently enough to trust for 1.16 or 1.17
#else
if (this.chunk instanceof LevelChunk)
{
@@ -451,6 +449,11 @@ public class ChunkWrapper implements IChunkWrapper
{
#if PRE_MC_1_18_2
// TODO: Check what to do in 1.18.1 and older
// since we don't currently handle this list,
// clear it to prevent memory leaks
chunksNeedingClientLightUpdating.clear();
#else
// update the chunks client lighting
@@ -1,12 +1,10 @@
package com.seibel.distanthorizons.common.wrappers.gui.updater;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.vertex.PoseStack;
import com.seibel.distanthorizons.api.enums.config.EUpdateBranch;
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
import com.seibel.distanthorizons.core.jar.ModGitInfo;
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
import com.seibel.distanthorizons.core.jar.ModJarInfo;
import com.seibel.distanthorizons.coreapi.ModInfo;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.jar.JarUtils;
@@ -15,8 +13,9 @@ import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
import net.minecraft.client.Minecraft;
#if POST_MC_1_20_1
import net.minecraft.client.gui.GuiGraphics;
#else
import com.mojang.blaze3d.vertex.PoseStack;
#endif
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.resources.ResourceLocation;
@@ -53,7 +52,7 @@ public class UpdateModScreen extends DhScreen
nextVer = ModrinthGetter.releaseNames.get(this.newVersionID);
break;
case NIGHTLY:
currentVer = ModGitInfo.Git_Main_Commit.substring(0,7);
currentVer = ModJarInfo.Git_Commit.substring(0,7);
nextVer = this.newVersionID.substring(0,7);
break;
}
@@ -48,6 +48,7 @@ import org.joml.Vector3f;
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;
#endif
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
@@ -103,6 +104,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
*/
public HashMap<IDimensionTypeWrapper, LightMapWrapper> lightmapByDimensionType = new HashMap<>();
/**
* Holds the render buffer that should be used when displaying levels to the screen.
* This is used for Optifine shader support so we can render directly to Optifine's level frame buffer.
*/
public int finalLevelFrameBufferId = -1;
@Override
@@ -255,9 +262,23 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
public int getTargetFrameBuffer()
{
int frameBufferOverrideId = DhApiRenderProxy.INSTANCE.targetFrameBufferOverride;
return (frameBufferOverrideId == -1) ? this.getRenderTarget().frameBufferId : frameBufferOverrideId;
if (frameBufferOverrideId != -1)
{
return frameBufferOverrideId;
}
// used so we can access the framebuffer shaders end up rendering to
if (AbstractOptifineAccessor.optifinePresent())
{
return this.finalLevelFrameBufferId;
}
return this.getRenderTarget().frameBufferId;
}
@Override
public void clearTargetFrameBuffer() { this.finalLevelFrameBufferId = -1; }
@Override
public int getDepthTextureId() { return this.getRenderTarget().getDepthTextureId(); }
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -66,6 +67,12 @@ public class DhLitWorldGenRegion extends WorldGenRegion
private final List<ChunkAccess> cache;
Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>();
/**
* Present to reduce the chance that we accidentally break underlying MC code that isn't thread safe,
* specifically: "it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap.getAndMoveToFirst()"
*/
ReentrantLock getChunkLock = new ReentrantLock();
#if PRE_MC_1_18_2
private ChunkPos overrideCenterPos = null;
@@ -90,6 +97,8 @@ public class DhLitWorldGenRegion extends WorldGenRegion
#endif
#endif
public DhLitWorldGenRegion(
ServerLevel serverLevel, DummyLightEngine lightEngine,
List<ChunkAccess> chunkList, ChunkStatus chunkStatus, int writeRadius,
@@ -104,6 +113,8 @@ public class DhLitWorldGenRegion extends WorldGenRegion
this.size = Mth.floor(Math.sqrt(chunkList.size()));
}
#if POST_MC_1_17_1
// Bypass BCLib mixin overrides.
@Override
@@ -205,7 +216,16 @@ public class DhLitWorldGenRegion extends WorldGenRegion
@Override
public ChunkAccess getChunk(int i, int j)
{
return this.getChunk(i, j, ChunkStatus.EMPTY);
try
{
// lock is to prevent issues with underlying MC code that doesn't support multithreading
this.getChunkLock.lock();
return this.getChunk(i, j, ChunkStatus.EMPTY);
}
finally
{
this.getChunkLock.unlock();
}
}
// Override to ensure no other mod mixins cause skipping the overrided
@@ -213,7 +233,16 @@ public class DhLitWorldGenRegion extends WorldGenRegion
@Override
public ChunkAccess getChunk(int i, int j, ChunkStatus chunkStatus)
{
return this.getChunk(i, j, chunkStatus, true);
try
{
// lock is to prevent issues with underlying MC code that doesn't support multithreading
this.getChunkLock.lock();
return this.getChunk(i, j, chunkStatus, true);
}
finally
{
this.getChunkLock.unlock();
}
}
// Use this instead of super.getChunk() to bypass C2ME concurrency checks
@@ -13,21 +13,20 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.locks.ReentrantLock;
public class RegionFileStorageExternalCache implements AutoCloseable
{
public final RegionFileStorage storage;
public static final int MAX_CACHE_SIZE = 16;
@Override
public void close() throws IOException
{
RegionFileCache cache;
while ((cache = this.regionFileCache.poll()) != null)
{
cache.file.close();
}
}
/**
* Present to reduce the chance that we accidentally break underlying MC code that isn't thread safe,
* specifically: "it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap.getAndMoveToFirst()"
*/
ReentrantLock getRegionFileLock = new ReentrantLock();
static class RegionFileCache
{
@@ -42,6 +41,8 @@ public class RegionFileStorageExternalCache implements AutoCloseable
}
public ConcurrentLinkedQueue<RegionFileCache> regionFileCache = new ConcurrentLinkedQueue<>();
public RegionFileStorageExternalCache(RegionFileStorage storage) { this.storage = storage; }
@@ -61,8 +62,20 @@ public class RegionFileStorageExternalCache implements AutoCloseable
try
{
this.getRegionFileLock.lock();
#if MC_1_16_5 || MC_1_17_1
rFile = this.storage.getRegionFile(pos);
// keeping the region cache size low helps prevent concurrency issues
if (this.storage.regionCache.size() > 150) // max 256
{
RegionFile removedFile = this.storage.regionCache.removeLast();
if (removedFile != null)
{
removedFile.close();
}
}
#else
rFile = this.storage.regionCache.getOrDefault(posLong, null);
#endif
@@ -85,6 +98,10 @@ public class RegionFileStorageExternalCache implements AutoCloseable
}
#endif
}
finally
{
this.getRegionFileLock.unlock();
}
}
if (retryCount >= maxRetryCount)
@@ -140,7 +157,7 @@ public class RegionFileStorageExternalCache implements AutoCloseable
@Nullable
public CompoundTag read(ChunkPos pos) throws IOException
{
RegionFile file = getRegionFile(pos);
RegionFile file = this.getRegionFile(pos);
if (file == null)
{
return null;
@@ -162,4 +179,16 @@ public class RegionFileStorageExternalCache implements AutoCloseable
}
}
@Override
public void close() throws IOException
{
RegionFileCache cache;
while ((cache = this.regionFileCache.poll()) != null)
{
cache.file.close();
}
}
}
@@ -122,6 +122,7 @@ public class WorldGenStructFeatManager extends #if PRE_MC_1_19_2 StructureFeatur
ChunkAccess chunk = _getChunk(sectionPos2.x(), sectionPos2.z(), ChunkStatus.STRUCTURE_REFERENCES);
if (chunk == null) return Stream.empty();
// FIXME getReferencesForFeature can throw ConcurrentModificationException's
return chunk.getReferencesForFeature(structureFeature).stream().map(pos -> {
SectionPos sectPos = SectionPos.of(ChunkPos.getX(pos), 0, ChunkPos.getZ(pos));
ChunkAccess startChunk = _getChunk(sectPos.x(), sectPos.z(), ChunkStatus.STRUCTURE_STARTS);
@@ -63,7 +63,7 @@ public final class StepStructureReference
for (ChunkAccess chunk : chunksToDo)
{
// System.out.println("StepStructureReference: "+chunk.getPos());
environment.params.generator.createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
this.environment.params.generator.createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
}
}
@@ -38,7 +38,7 @@ public final class StepStructureStart
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private static final ChunkStatus STATUS = ChunkStatus.STRUCTURE_STARTS;
private static final ReentrantLock structurePlacementLock = new ReentrantLock();
private static final ReentrantLock STRUCTURE_PLACEMENT_LOCK = new ReentrantLock();
private final BatchGenerationEnvironment environment;
@@ -96,7 +96,7 @@ public final class StepStructureStart
// hopefully this shouldn't cause any performance issues (this step is generally quite quick so hopefully it should be fine)
// and should prevent some concurrency issues
structurePlacementLock.lock();
STRUCTURE_PLACEMENT_LOCK.lock();
#if PRE_MC_1_19_2
environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures,
@@ -138,8 +138,9 @@ public final class StepStructureStart
}
}
structurePlacementLock.unlock();
#endif
STRUCTURE_PLACEMENT_LOCK.unlock();
}
}
}
@@ -37,6 +37,7 @@ accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/min
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
accessible method net/minecraft/world/level/chunk/storage/RegionFileStorage getRegionFile (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/storage/RegionFile;
accessible field net/minecraft/world/level/chunk/storage/RegionFileStorage folder Ljava/io/File;
accessible field net/minecraft/world/level/chunk/storage/RegionFileStorage regionCache Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;
accessible field net/minecraft/world/level/chunk/storage/ChunkStorage worker Lnet/minecraft/world/level/chunk/storage/IOWorker;
accessible field net/minecraft/world/level/chunk/storage/IOWorker storage Lnet/minecraft/world/level/chunk/storage/RegionFileStorage;
@@ -37,6 +37,7 @@ accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/min
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
accessible method net/minecraft/world/level/chunk/storage/RegionFileStorage getRegionFile (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/chunk/storage/RegionFile;
accessible field net/minecraft/world/level/chunk/storage/RegionFileStorage folder Ljava/io/File;
accessible field net/minecraft/world/level/chunk/storage/RegionFileStorage regionCache Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;
accessible field net/minecraft/world/level/chunk/storage/ChunkStorage worker Lnet/minecraft/world/level/chunk/storage/IOWorker;
accessible field net/minecraft/world/level/chunk/storage/IOWorker storage Lnet/minecraft/world/level/chunk/storage/RegionFileStorage;
+3 -3
View File
@@ -1,5 +1,5 @@
{
"git_main_branch": "${git_main_branch}",
"git_main_commit": "${git_main_commit}",
"git_core_commit": "${git_core_commit}"
"info_git_commit": "${info_git_commit}",
"info_git_branch": "${info_git_branch}",
"info_build_source": "${info_build_source}"
}
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.fabric;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
import com.seibel.distanthorizons.core.config.ConfigBase;
import com.seibel.distanthorizons.core.jar.ModGitInfo;
import com.seibel.distanthorizons.core.jar.ModJarInfo;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.*;
import com.seibel.distanthorizons.common.LodCommonMain;
@@ -80,9 +80,9 @@ public class FabricMain
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
// Print git info (Useful for dev builds)
LOGGER.info("DH Branch: " + ModGitInfo.Git_Main_Branch);
LOGGER.info("DH Commit: " + ModGitInfo.Git_Main_Commit);
LOGGER.info("DH-Core Commit: " + ModGitInfo.Git_Core_Commit);
LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch);
LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit);
LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source);
IModChecker modChecker = SingletonInjector.INSTANCE.get(IModChecker.class);
if (modChecker.isModLoaded("sodium"))
@@ -8,6 +8,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftCli
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.DynamicTexture;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -15,24 +16,27 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LightTexture.class)
@Mixin(DynamicTexture.class)
public class MixinLightmap
{
@Shadow
@Final
private NativeImage lightPixels;
private NativeImage pixels;
@Inject(method = "updateLightTexture", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V"))
public void updateLightTexture(float f, CallbackInfo ci)
@Inject(method = "Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V", at = @At("HEAD"), cancellable = true)
public void updateLightTexture(CallbackInfo ci)
{
// since the light map is always updated on the client render thread we should be able to access the client level at the same time
IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
if (
mc == null ||
mc.getWrappedClientLevel() == null
)
return;
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel();
//ApiShared.LOGGER.info("Lightmap update");
MinecraftRenderWrapper.INSTANCE.updateLightmap(this.lightPixels, clientLevel);
MinecraftRenderWrapper.INSTANCE.updateLightmap(this.pixels, clientLevel);
}
}
@@ -31,12 +31,18 @@ public class MixinChunkMap
@Inject(method = "save", at = @At(value = "INVOKE", target = CHUNK_SERIALIZER_WRITE))
private void onChunkSave(ChunkAccess chunk, CallbackInfoReturnable<Boolean> ci)
{
// corrupt/incomplete chunk validation
#if MC_1_16_5 || MC_1_17_1
// no validation necessary
#else
//=====================================//
// corrupt/incomplete chunk validation //
//=====================================//
// MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks)
// this should prevent that from happening
// this logic should prevent that from happening
#if MC_1_16_5 || MC_1_17_1
if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect())
{
return;
}
#else
if (chunk.isUnsaved() || chunk.isUpgrading() || !chunk.isLightCorrect())
{
return;
@@ -44,11 +50,14 @@ public class MixinChunkMap
#endif
// biome validation
//==================//
// biome validation //
//==================//
// some chunks may be missing their biomes, which cause issues when attempting to save them
#if MC_1_16_5 || MC_1_17_1
if (chunk.getBiomes() == null)
{
// in 1.16.5 some chunks may be missing their biomes, which cause issues when attempting to save them
return;
}
#else
@@ -59,15 +68,15 @@ public class MixinChunkMap
}
catch (Exception e)
{
// some chunks may be missing their biomes, which cause issues when attempting to save them
return;
}
#endif
ServerApi.INSTANCE.serverChunkSaveEvent(
new ChunkWrapper(chunk, level, ServerLevelWrapper.getWrapper(level)),
ServerLevelWrapper.getWrapper(level)
new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)),
ServerLevelWrapper.getWrapper(this.level)
);
}
@@ -20,35 +20,53 @@
package com.seibel.distanthorizons.forge;
import com.seibel.distanthorizons.common.util.ProxyUtil;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.api.internal.SharedApi;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.client.multiplayer.ClientLevel;
#if PRE_MC_1_19_2
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
#else
import net.minecraftforge.event.level.ChunkEvent;
import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
#endif
#if POST_MC_1_18_2
import net.minecraftforge.client.event.RenderLevelStageEvent;
#else
import net.minecraftforge.client.event.RenderBlockOverlayEvent;
#endif
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.lwjgl.opengl.GL32;
/**
* This handles all events sent to the client,
* and is the starting point for most of the mod.
@@ -60,7 +78,7 @@ public class ForgeClientProxy
{
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private static SimpleChannel multiversePluginChannel;
@@ -276,4 +294,42 @@ public class ForgeClientProxy
}
}
//===========//
// rendering //
//===========//
@SubscribeEvent
#if POST_MC_1_18_2
public void afterLevelRenderEvent(RenderLevelStageEvent event)
#else
public void afterLevelRenderEvent(RenderBlockOverlayEvent event)
#endif
{
#if POST_MC_1_20_1
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_LEVEL)
#elif POST_MC_1_18_2
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_SOLID_BLOCKS)
#else
// FIXME: Is this the correct location for 1.16 & 1.17???
// I couldnt find anything for rendering after the level, so is rendering after overlays ok?
if (event.getOverlayType() == RenderBlockOverlayEvent.OverlayType.BLOCK)
#endif
{
try
{
// should generally only need to be set once per game session
// allows DH to render directly to Optifine's level frame buffer,
// allowing better shader support
MinecraftRenderWrapper.INSTANCE.finalLevelFrameBufferId = GL32.glGetInteger(GL32.GL_FRAMEBUFFER_BINDING);
}
catch (Exception | Error e)
{
LOGGER.error("Unexpected error in afterLevelRenderEvent: "+e.getMessage(), e);
}
}
}
}
@@ -26,7 +26,7 @@ import com.seibel.distanthorizons.common.forge.LodForgeMethodCaller;
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
import com.seibel.distanthorizons.core.jar.ModGitInfo;
import com.seibel.distanthorizons.core.jar.ModJarInfo;
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor;
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
import com.seibel.distanthorizons.coreapi.ModInfo;
@@ -69,7 +69,6 @@ import net.minecraftforge.client.model.data.ModelDataMap;
import java.util.Random;
#else
import net.minecraft.util.RandomSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.client.model.data.ModelData;
#endif
@@ -115,9 +114,9 @@ public class ForgeMain implements LodForgeMethodCaller
LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION);
// Print git info (Useful for dev builds)
LOGGER.info("DH Branch: " + ModGitInfo.Git_Main_Branch);
LOGGER.info("DH Commit: " + ModGitInfo.Git_Main_Commit);
LOGGER.info("DH-Core Commit: " + ModGitInfo.Git_Core_Commit);
LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch);
LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit);
LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source);
client_proxy = new ForgeClientProxy();
MinecraftForge.EVENT_BUS.register(client_proxy);
@@ -8,6 +8,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftCli
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.DynamicTexture;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -15,24 +16,27 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LightTexture.class)
@Mixin(DynamicTexture.class)
public class MixinLightmap
{
@Shadow
@Final
private NativeImage lightPixels;
private NativeImage pixels;
@Inject(method = "updateLightTexture", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V"))
public void updateLightTexture(float f, CallbackInfo ci)
@Inject(method = "Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V", at = @At("HEAD"), cancellable = true)
public void updateLightTexture(CallbackInfo ci)
{
// since the light map is always updated on the client render thread we should be able to access the client level at the same time
IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
if (
mc == null ||
mc.getWrappedClientLevel() == null
)
return;
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel();
//ApiShared.LOGGER.info("Lightmap update");
MinecraftRenderWrapper.INSTANCE.updateLightmap(this.lightPixels, clientLevel);
MinecraftRenderWrapper.INSTANCE.updateLightmap(this.pixels, clientLevel);
}
}
+4 -4
View File
@@ -18,7 +18,7 @@ mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues
mod_discord=https://discord.gg/xAB8G4cENx
# Global Plugin Versions
manifold_version=2023.1.28
manifold_version=2023.1.29
nightconfig_version=3.6.6
lz4_version=1.8.0
sqlite_jdbc_version=3.43.0.0
@@ -35,9 +35,9 @@ joml_version=1.10.2
# These are here so they can be changed with cmd arguments
# If they are null, they would be automatically set
# (This is mainly used for the CI)
gitMainCommit=null
gitCoreCommit=null
gitMainBranch=null
infoGitCommit=null
infoGitBranch=null
infoBuildSource=User
# Internal Properties (These are set at runtime for Forgix to merge jar's)
versionStr=
+2 -1
View File
@@ -4,12 +4,13 @@ pluginManagement {
name "Fabric"
url "https://maven.fabricmc.net/"
}
// TODO: Stop using Forge for versions with NeoForge
maven {
name "Forge"
url "https://maven.minecraftforge.net/"
}
maven {
name "Architectury (Better Forge because regular Forge is annoying)"
name "Architectury (Better Forge because regular Forge is annoying)" // TODO: Once we switch to NeoForge, would it's gradle work better? or will it have Forge's problems in it
url "https://maven.architectury.dev/"
}
maven {
+1 -1
View File
@@ -7,7 +7,7 @@ accessWidenerVersion=1_16
builds_for=fabric,forge
# Fabric loader
fabric_loader_version=0.14.21
fabric_loader_version=0.14.24
fabric_api_version=0.42.0+1.16
# Fabric mod versions
modmenu_version=1.16.22
+1 -1
View File
@@ -7,7 +7,7 @@ accessWidenerVersion=1_17
builds_for=fabric,forge
# Fabric loader
fabric_loader_version=0.14.21
fabric_loader_version=0.14.24
fabric_api_version=0.46.1+1.17
# Fabric mod versions
modmenu_version=2.0.17
+2 -2
View File
@@ -7,7 +7,7 @@ accessWidenerVersion=1_18
builds_for=fabric,forge
# Fabric loader
fabric_loader_version=0.14.21
fabric_loader_version=0.14.24
fabric_api_version=0.76.0+1.18.2
# Fabric mod versions
modmenu_version=3.2.5
@@ -16,7 +16,7 @@ fabric_api_version=0.76.0+1.18.2
phosphor_version_fabric=3573395
lithium_version=mc1.18.2-0.10.3
sodium_version=mc1.18.2-0.4.1
iris_version=1.6.6+1.18.2
iris_version=1.6.10+1.18.2
bclib_version=1.4.6
immersive_portals_version=v1.4.11-1.18
canvas_version=mc118:1.0.2616
+4 -4
View File
@@ -7,15 +7,15 @@ accessWidenerVersion=1_19_2
builds_for=fabric,forge
# Fabric loader
fabric_loader_version=0.14.21
fabric_api_version=0.76.0+1.19.2
fabric_loader_version=0.14.24
fabric_api_version=0.76.1+1.19.2
# Fabric mod versions
modmenu_version=4.2.0-beta.2
starlight_version_fabric=
phosphor_version_fabric=
lithium_version=
sodium_version=mc1.19.2-0.4.4
iris_version=1.6.6+1.19.2
iris_version=1.6.10+1.19.2
bclib_version=2.1.6
immersive_portals_version=
canvas_version=mc119-1.0.2480
@@ -37,7 +37,7 @@ fabric_api_version=0.76.0+1.19.2
enable_canvas=0
# Forge loader
forge_version=43.2.14
forge_version=43.3.2
# Forge mod versions
starlight_version_forge=
terraforged_version=
+6 -6
View File
@@ -1,21 +1,21 @@
# 1.19.4 version
java_version=17
minecraft_version=1.19.4
parchment_version=1.19.3:2023.06.25
parchment_version=1.19.4:2023.06.26
compatible_minecraft_versions=["1.19.4"]
accessWidenerVersion=1_19_4
builds_for=fabric,forge
# Fabric loader
fabric_loader_version=0.14.21
fabric_api_version=0.83.0+1.19.4
fabric_loader_version=0.14.24
fabric_api_version=0.87.1+1.19.4
# Fabric mod versions
modmenu_version=6.2.3
modmenu_version=6.3.1
starlight_version_fabric=
phosphor_version_fabric=
lithium_version=
sodium_version=mc1.19.4-0.4.10
iris_version=1.6.6+1.19.4
iris_version=1.6.10+1.19.4
bclib_version=2.3.3
immersive_portals_version=
canvas_version=
@@ -37,7 +37,7 @@ fabric_api_version=0.83.0+1.19.4
enable_canvas=0
# Forge loader
forge_version=45.1.0
forge_version=45.2.4
# Forge mod versions
starlight_version_forge=
terraforged_version=
+7 -7
View File
@@ -1,21 +1,21 @@
# 1.20.1 version
java_version=17
minecraft_version=1.20.1
parchment_version=1.19.3:2023.06.25
parchment_version=1.20.1:2023.09.03
compatible_minecraft_versions=["1.20", "1.20.1"]
accessWidenerVersion=1_20
builds_for=fabric,forge
# Fabric loader
fabric_loader_version=0.14.21
fabric_api_version=0.85.0+1.20.1
fabric_loader_version=0.14.24
fabric_api_version=0.90.4+1.20.1
# Fabric mod versions
modmenu_version=7.0.1
modmenu_version=7.2.2
starlight_version_fabric=
phosphor_version_fabric=
lithium_version=
sodium_version=mc1.20.1-0.5.1
iris_version=1.6.8+1.20.1
sodium_version=mc1.20.1-0.5.3
iris_version=1.6.10+1.20.1
bclib_version=3.0.12
immersive_portals_version=
canvas_version=
@@ -37,7 +37,7 @@ fabric_api_version=0.85.0+1.20.1
enable_canvas=0
# Forge loader
forge_version=47.0.1
forge_version=47.2.1
# Forge mod versions
starlight_version_forge=
terraforged_version=
+4 -4
View File
@@ -1,21 +1,21 @@
# 1.20.2 version
java_version=17
minecraft_version=1.20.2
parchment_version=1.19.3:2023.06.25
parchment_version=1.20.1:2023.09.03
compatible_minecraft_versions=["1.20.2"]
accessWidenerVersion=1_20_2
builds_for=fabric,forge
# Fabric loader
fabric_loader_version=0.14.22
fabric_api_version=0.89.2+1.20.2
fabric_loader_version=0.14.24
fabric_api_version=0.90.4+1.20.2
# Fabric mod versions
modmenu_version=8.0.0
starlight_version_fabric=
phosphor_version_fabric=
lithium_version=
sodium_version=mc1.20.2-0.5.3
iris_version=1.6.9+1.20.2
iris_version=1.6.10+1.20.2
bclib_version=3.0.13
immersive_portals_version=
canvas_version=