From c00aa6d6278b7011411c78fa79d2c27e1d8fc672 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 11 Aug 2024 20:05:24 -0500 Subject: [PATCH 01/19] Add MC 1.21.1 --- gradle.properties | 2 +- versionProperties/{1.21.properties => 1.21.1.properties} | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename versionProperties/{1.21.properties => 1.21.1.properties} (91%) diff --git a/gradle.properties b/gradle.properties index cc28ca70f..c0fd0ff24 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,7 +49,7 @@ 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.21 +mcVer=1.21.1 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment #minecraftMemoryJavaArg="-Xmx4G" diff --git a/versionProperties/1.21.properties b/versionProperties/1.21.1.properties similarity index 91% rename from versionProperties/1.21.properties rename to versionProperties/1.21.1.properties index 647a2b799..0498f8503 100644 --- a/versionProperties/1.21.properties +++ b/versionProperties/1.21.1.properties @@ -1,8 +1,8 @@ -# 1.21 version +# 1.21.1 version java_version=21 -minecraft_version=1.21 +minecraft_version=1.21.1 parchment_version=1.20.6:2024.05.01 -compatible_minecraft_versions=["1.21.0"] +compatible_minecraft_versions=["1.21.0", "1.21.1"] accessWidenerVersion=1_20_6 builds_for=fabric,neoforge # forge is broken due to gradle/build script issues @@ -39,7 +39,7 @@ fabric_api_version=0.100.1+1.21 # (Neo)Forge loader forge_version=50.0.19 -neoforge_version=21.0.4-beta +neoforge_version=21.1.6 # (Neo)Forge mod versions starlight_version_forge= terraforged_version= From cd856b86c7c56733894fb58b5511e500d0537d2c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 11 Aug 2024 21:55:19 -0500 Subject: [PATCH 02/19] Fix DhApiChunk setDataPoints failing for empty lists --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index dac51a9ee..c63a509f9 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit dac51a9eea0b2d78b8c320996ec9b40fb307370d +Subproject commit c63a509f9e5d3c7b4ce7c8a9850b44f400c01298 From 95641e2f4e82ef263de8d90f0892576da5902c91 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 11 Aug 2024 22:01:29 -0500 Subject: [PATCH 03/19] Allow adding empty lists to DhApiChunk --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index c63a509f9..a98955530 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit c63a509f9e5d3c7b4ce7c8a9850b44f400c01298 +Subproject commit a98955530fbe75a5c30cd97050aa42d68834aa0a From 897d5b0b11a1e077d7d66c74ff25a560d8268674 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 12 Aug 2024 19:53:48 -0500 Subject: [PATCH 04/19] Change MC 1.21 -> 1.21.1 in CI version --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 181343627..6f4eadabc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ build: stage: build parallel: matrix: - - MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4", "1.20.6", "1.21"] + - MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4", "1.20.6", "1.21.1"] script: # this both runs the unit tests and assembles the code - ./gradlew clean -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/; From 625f1e700fc533c91d35e0edcb72747c8be72ac4 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 12 Aug 2024 21:05:15 -0500 Subject: [PATCH 05/19] Fix MC 1.21 / 1.21.1 --- .gitlab-ci.yml | 2 +- .../common/wrappers/WrapperFactory.java | 42 ++++----------- .../mimicObject/ChunkLoader.java | 2 +- .../mimicObject/DhLitWorldGenRegion.java | 2 +- versionProperties/1.21.1.properties | 4 +- versionProperties/1.21.properties | 53 +++++++++++++++++++ 6 files changed, 67 insertions(+), 38 deletions(-) create mode 100644 versionProperties/1.21.properties diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f4eadabc..56aedf4af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ build: stage: build parallel: matrix: - - MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4", "1.20.6", "1.21.1"] + - MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4", "1.20.6", "1.21", "1.21.1"] script: # this both runs the unit tests and assembles the code - ./gradlew clean -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java index 293a53037..f1916a214 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java @@ -155,7 +155,7 @@ public class WrapperFactory implements IWrapperFactory } } - #if MC_VER <= MC_1_21 + //#if MC_VER <= MC_1_XX_X else if (objectArray.length == 2) { // correct number of parameters from the API @@ -201,16 +201,7 @@ public class WrapperFactory implements IWrapperFactory { throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); } - #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. - - // 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 + //#endif } /** * Note: when this is updated for different MC versions, @@ -220,16 +211,13 @@ public class WrapperFactory implements IWrapperFactory { String[] expectedClassNames; - #if MC_VER <= MC_1_21 + //#if MC_VER <= MC_1_XX_X expectedClassNames = new String[] { ChunkAccess.class.getName(), ServerLevel.class.getName() + "] or [" + ClientLevel.class.getName() }; - #else - // See preprocessor comment in createChunkWrapper() for full documentation - not implemented for this version of Minecraft! - #endif + //#endif return createWrapperErrorMessage("Chunk wrapper", expectedClassNames, objectArray); } @@ -268,7 +256,7 @@ public class WrapperFactory implements IWrapperFactory Biome biome = (Biome) objectArray[0]; return BiomeWrapper.getBiomeWrapper(biome, coreLevelWrapper); - #elif MC_VER <= MC_1_21 + #else if (!(objectArray[0] instanceof Holder) || !(((Holder) objectArray[0]).value() instanceof Biome)) { throw new ClassCastException(createBiomeWrapperErrorMessage(objectArray)); @@ -276,9 +264,6 @@ public class WrapperFactory implements IWrapperFactory Holder biomeHolder = (Holder) objectArray[0]; return BiomeWrapper.getBiomeWrapper(biomeHolder, coreLevelWrapper); - #else - // See preprocessor comment in createChunkWrapper() for full documentation (not a typo, check createChunkWrapper()'s else statement for full documentation) - not implemented for this version of Minecraft! #endif } /** @@ -291,11 +276,8 @@ public class WrapperFactory implements IWrapperFactory #if MC_VER < MC_1_18_2 expectedClassNames = new String[] { Biome.class.getName() }; - #elif MC_VER <= MC_1_21 - expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" }; #else - // See preprocessor comment in createChunkWrapper() for full documentation - not implemented for this version of Minecraft! + expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" }; #endif return createWrapperErrorMessage("Biome wrapper", expectedClassNames, objectArray); @@ -312,7 +294,7 @@ public class WrapperFactory implements IWrapperFactory - #if MC_VER <= MC_1_21 + //#if MC_VER <= MC_1_XX_X if (objectArray.length != 1) { throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray)); @@ -324,10 +306,7 @@ public class WrapperFactory implements IWrapperFactory BlockState blockState = (BlockState) objectArray[0]; return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper); - #else - // See preprocessor comment in createChunkWrapper() for full documentation (not a typo, check createChunkWrapper()'s else statement for full documentation) - not implemented for this version of Minecraft! - #endif + //#endif } /** * Note: when this is updated for different MC versions, @@ -339,11 +318,8 @@ public class WrapperFactory implements IWrapperFactory #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 expectedClassNames = new String[] { Biome.class.getName() }; - #elif MC_VER <= MC_1_21 - expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" }; #else - // See preprocessor comment in createChunkWrapper() for full documentation - not implemented for this version of Minecraft! + expectedClassNames = new String[] { Holder.class.getName()+"<"+Biome.class.getName()+">" }; #endif return createWrapperErrorMessage("BlockState wrapper", expectedClassNames, objectArray); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index 2b4cf1052..6e98738a6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -85,7 +85,7 @@ import net.minecraft.world.level.material.Fluids; #if MC_VER == MC_1_20_6 import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.chunk.status.ChunkType; -#elif MC_VER == MC_1_21 +#elif MC_VER >= MC_1_21 import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.chunk.status.ChunkType; #endif diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java index 30632bef1..48b5a3fb7 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java @@ -63,7 +63,7 @@ import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.status.*; #endif -#if MC_VER == MC_1_21 +#if MC_VER >= MC_1_21 import net.minecraft.util.StaticCache2D; import com.google.common.collect.ImmutableList; import net.minecraft.server.level.GenerationChunkHolder; diff --git a/versionProperties/1.21.1.properties b/versionProperties/1.21.1.properties index 0498f8503..9a4da88c7 100644 --- a/versionProperties/1.21.1.properties +++ b/versionProperties/1.21.1.properties @@ -2,7 +2,7 @@ java_version=21 minecraft_version=1.21.1 parchment_version=1.20.6:2024.05.01 -compatible_minecraft_versions=["1.21.0", "1.21.1"] +compatible_minecraft_versions=["1.21.1"] accessWidenerVersion=1_20_6 builds_for=fabric,neoforge # forge is broken due to gradle/build script issues @@ -38,7 +38,7 @@ fabric_api_version=0.100.1+1.21 enable_canvas=0 # (Neo)Forge loader -forge_version=50.0.19 +forge_version= neoforge_version=21.1.6 # (Neo)Forge mod versions starlight_version_forge= diff --git a/versionProperties/1.21.properties b/versionProperties/1.21.properties new file mode 100644 index 000000000..c2c73633b --- /dev/null +++ b/versionProperties/1.21.properties @@ -0,0 +1,53 @@ +# 1.21 version +java_version=21 +minecraft_version=1.21 +parchment_version=1.20.6:2024.05.01 +compatible_minecraft_versions=["1.21"] +accessWidenerVersion=1_20_6 +builds_for=fabric,neoforge +# forge is broken due to gradle/build script issues + +# Fabric loader +fabric_loader_version=0.15.11 +fabric_api_version=0.100.1+1.21 + # Fabric mod versions + modmenu_version=11.0.0-beta.1 + starlight_version_fabric= + phosphor_version_fabric= + lithium_version= + sodium_version=mc1.21-0.5.9 + iris_version=1.7.1+1.21 + bclib_version= + immersive_portals_version= + canvas_version= + + fabric_incompatibility_list={ "iris": "<=1.7.4" } + fabric_recommend_list={} + + # Fabric mod run + # 0 = Don't enable and don't run + # 1 = Can be referenced in code but doesn't run + # 2 = Can be referenced in code and runs in client + enable_starlight=0 + enable_phosphor=0 + enable_sodium=1 + enable_lithium=0 + enable_iris=1 + enable_bclib=0 + enable_immersive_portals=0 + enable_canvas=0 + +# (Neo)Forge loader +forge_version=50.0.19 +neoforge_version=21.0.4-beta + # (Neo)Forge mod versions + starlight_version_forge= + terraforged_version= + + # (Neo)Forge mod run + # 0 = Don't enable and don't run + # 1 = Can be referenced in code but doesn't run + # 2 = Can be referenced in code and runs in client + enable_starlight_forge=0 + enable_terraforged=0 + enable_terrafirmacraft=0 From 2f6eaf79bd3d1878ff4bf98021d0221bccf52345 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 12 Aug 2024 21:47:58 -0500 Subject: [PATCH 06/19] Add optional DhApiChunk validation for world gen --- coreSubProjects | 2 +- .../fabric/testing/TestWorldGenerator.java | 102 +++++++++++++----- 2 files changed, 75 insertions(+), 29 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index a98955530..c7c5ab17b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit a98955530fbe75a5c30cd97050aa42d68834aa0a +Subproject commit c7c5ab17bc489d7d05da46f76cf410ad2903f395 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java index d5cf9d578..825859e89 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java @@ -11,17 +11,29 @@ import com.seibel.distanthorizons.api.objects.data.DhApiChunk; import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; +import com.seibel.distanthorizons.core.config.Config; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicInteger; public class TestWorldGenerator extends AbstractDhApiChunkWorldGenerator { + private static final int MAX_QUEUED_TASKS_PER_THREAD = 10; + private final ServerLevel level; private final IDhApiLevelWrapper levelWrapper; + private final AtomicInteger genCountRef = new AtomicInteger(0); + + + + //=============// + // constructor // + //=============// + public TestWorldGenerator(ServerLevel level) { this.level = level; @@ -29,12 +41,30 @@ public class TestWorldGenerator extends AbstractDhApiChunkWorldGenerator } + + //============// + // properties // + //============// + @Override public EDhApiWorldGeneratorReturnType getReturnType() { return EDhApiWorldGeneratorReturnType.API_CHUNKS; } @Override - public boolean isBusy() { return false; } + public boolean isBusy() + { + int worldGenThreadCount = Math.max(Config.Client.Advanced.MultiThreading.numberOfWorldGenerationThreads.get(), 1); + int maxWorldGenTaskCount = worldGenThreadCount * MAX_QUEUED_TASKS_PER_THREAD; + return this.genCountRef.get() > maxWorldGenTaskCount; + } + @Override + public boolean runApiChunkValidation() { return true; } + + + + //==================// + // chunk generation // + //==================// @Override public Object[] generateChunk(int chunkX, int chunkZ, EDhApiDistantGeneratorMode eDhApiDistantGeneratorMode) @@ -46,44 +76,60 @@ public class TestWorldGenerator extends AbstractDhApiChunkWorldGenerator @Override public DhApiChunk generateApiChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode) { - // this test is only validated for 1.18.2 and up - // (and it is only needed when testing world gen overrides/API chunks, so it isn't normally needed) - #if MC_VER >= MC_1_18_2 - ChunkAccess chunk = this.level.getChunk(chunkPosX, chunkPosZ); - ChunkWrapper chunkWrapper = new ChunkWrapper(chunk, null, null); - - int minBuildHeight = chunkWrapper.getMinBuildHeight(); - int maxBuildHeight = chunkWrapper.getMaxBuildHeight(); - - DhApiChunk apiChunk = DhApiChunk.create(chunkPosX, chunkPosZ, minBuildHeight, maxBuildHeight); - for (int x = 0; x < 16; x++) + try { - for (int z = 0; z < 16; z++) + this.genCountRef.incrementAndGet(); + + + // this test is only validated for 1.18.2 and up + // (and it is only needed when testing world gen overrides/API chunks, so it isn't normally needed) + #if MC_VER >= MC_1_18_2 + ChunkAccess chunk = this.level.getChunk(chunkPosX, chunkPosZ); + + + int minBuildHeight = this.level.getMinBuildHeight(); + int maxBuildHeight = this.level.getMaxBuildHeight(); + + DhApiChunk apiChunk = DhApiChunk.create(chunkPosX, chunkPosZ, minBuildHeight, maxBuildHeight); + for (int x = 0; x < 16; x++) { - ArrayList dataPoints = new ArrayList<>(); - - IDhApiBlockStateWrapper block = null; - IDhApiBiomeWrapper biome = null; - - for (int y = minBuildHeight; y < maxBuildHeight; y++) + for (int z = 0; z < 16; z++) { - block = DhApi.Delayed.wrapperFactory.getBlockStateWrapper(new Object[]{chunk.getBlockState(new BlockPos(x, y, z))}, this.levelWrapper); - biome = DhApi.Delayed.wrapperFactory.getBiomeWrapper(new Object[]{chunk.getNoiseBiome(x, y, z)}, this.levelWrapper); - dataPoints.add(DhApiTerrainDataPoint.create((byte) 0, 0, 15, y, y + 1, block, biome)); + ArrayList dataPoints = new ArrayList<>(); + + IDhApiBlockStateWrapper block = null; + IDhApiBiomeWrapper biome = null; + + for (int y = minBuildHeight; y < maxBuildHeight; y++) + { + block = DhApi.Delayed.wrapperFactory.getBlockStateWrapper(new Object[]{chunk.getBlockState(new BlockPos(x, y, z))}, this.levelWrapper); + biome = DhApi.Delayed.wrapperFactory.getBiomeWrapper(new Object[]{chunk.getNoiseBiome(x, y, z)}, this.levelWrapper); + dataPoints.add(DhApiTerrainDataPoint.create((byte) 0, 0, 15, y, y + 1, block, biome)); + } + + apiChunk.setDataPoints(x, z, dataPoints); } - - apiChunk.setDataPoints(x, z, dataPoints); } + return apiChunk; + #else + return null; + #endif + } + finally + { + this.genCountRef.decrementAndGet(); } - return apiChunk; - #else - return null; - #endif } @Override public void preGeneratorTaskStart() { /* do nothing */ } + + + //=========// + // cleanup // + //=========// + @Override public void close() { /* do nothing */ } From af205a50b4217d75a40646d12367f1721a6f5872 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 12 Aug 2024 22:20:14 -0500 Subject: [PATCH 07/19] Deprecate IDhApiWorldGenerator.isBusy(), task queuing is now handled internally --- coreSubProjects | 2 +- .../fabric/testing/TestWorldGenerator.java | 76 +++++++------------ 2 files changed, 28 insertions(+), 50 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index c7c5ab17b..2cf952fb7 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit c7c5ab17bc489d7d05da46f76cf410ad2903f395 +Subproject commit 2cf952fb768e38567698c8d58c80d328b7685a08 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java index 825859e89..fe4a59b55 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/testing/TestWorldGenerator.java @@ -21,13 +21,9 @@ import java.util.concurrent.atomic.AtomicInteger; public class TestWorldGenerator extends AbstractDhApiChunkWorldGenerator { - private static final int MAX_QUEUED_TASKS_PER_THREAD = 10; - private final ServerLevel level; private final IDhApiLevelWrapper levelWrapper; - private final AtomicInteger genCountRef = new AtomicInteger(0); - //=============// @@ -49,14 +45,6 @@ public class TestWorldGenerator extends AbstractDhApiChunkWorldGenerator @Override public EDhApiWorldGeneratorReturnType getReturnType() { return EDhApiWorldGeneratorReturnType.API_CHUNKS; } - @Override - public boolean isBusy() - { - int worldGenThreadCount = Math.max(Config.Client.Advanced.MultiThreading.numberOfWorldGenerationThreads.get(), 1); - int maxWorldGenTaskCount = worldGenThreadCount * MAX_QUEUED_TASKS_PER_THREAD; - return this.genCountRef.get() > maxWorldGenTaskCount; - } - @Override public boolean runApiChunkValidation() { return true; } @@ -76,49 +64,39 @@ public class TestWorldGenerator extends AbstractDhApiChunkWorldGenerator @Override public DhApiChunk generateApiChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode) { - try + // this test is only validated for 1.18.2 and up + // (and it is only needed when testing world gen overrides/API chunks, so it isn't normally needed) + #if MC_VER >= MC_1_18_2 + ChunkAccess chunk = this.level.getChunk(chunkPosX, chunkPosZ); + + + int minBuildHeight = this.level.getMinBuildHeight(); + int maxBuildHeight = this.level.getMaxBuildHeight(); + + DhApiChunk apiChunk = DhApiChunk.create(chunkPosX, chunkPosZ, minBuildHeight, maxBuildHeight); + for (int x = 0; x < 16; x++) { - this.genCountRef.incrementAndGet(); - - - // this test is only validated for 1.18.2 and up - // (and it is only needed when testing world gen overrides/API chunks, so it isn't normally needed) - #if MC_VER >= MC_1_18_2 - ChunkAccess chunk = this.level.getChunk(chunkPosX, chunkPosZ); - - - int minBuildHeight = this.level.getMinBuildHeight(); - int maxBuildHeight = this.level.getMaxBuildHeight(); - - DhApiChunk apiChunk = DhApiChunk.create(chunkPosX, chunkPosZ, minBuildHeight, maxBuildHeight); - for (int x = 0; x < 16; x++) + for (int z = 0; z < 16; z++) { - for (int z = 0; z < 16; z++) + ArrayList dataPoints = new ArrayList<>(); + + IDhApiBlockStateWrapper block = null; + IDhApiBiomeWrapper biome = null; + + for (int y = minBuildHeight; y < maxBuildHeight; y++) { - ArrayList dataPoints = new ArrayList<>(); - - IDhApiBlockStateWrapper block = null; - IDhApiBiomeWrapper biome = null; - - for (int y = minBuildHeight; y < maxBuildHeight; y++) - { - block = DhApi.Delayed.wrapperFactory.getBlockStateWrapper(new Object[]{chunk.getBlockState(new BlockPos(x, y, z))}, this.levelWrapper); - biome = DhApi.Delayed.wrapperFactory.getBiomeWrapper(new Object[]{chunk.getNoiseBiome(x, y, z)}, this.levelWrapper); - dataPoints.add(DhApiTerrainDataPoint.create((byte) 0, 0, 15, y, y + 1, block, biome)); - } - - apiChunk.setDataPoints(x, z, dataPoints); + block = DhApi.Delayed.wrapperFactory.getBlockStateWrapper(new Object[]{chunk.getBlockState(new BlockPos(x, y, z))}, this.levelWrapper); + biome = DhApi.Delayed.wrapperFactory.getBiomeWrapper(new Object[]{chunk.getNoiseBiome(x, y, z)}, this.levelWrapper); + dataPoints.add(DhApiTerrainDataPoint.create((byte) 0, 0, 15, y, y + 1, block, biome)); } + + apiChunk.setDataPoints(x, z, dataPoints); } - return apiChunk; - #else - return null; - #endif - } - finally - { - this.genCountRef.decrementAndGet(); } + return apiChunk; + #else + return null; + #endif } @Override From b4822740f4d0e0ce1b9a4a3da464bb211e38e74c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 13 Aug 2024 07:33:04 -0500 Subject: [PATCH 08/19] temporarily break 1.17 compiling to test gitlab bages --- .../com/seibel/distanthorizons/fabric/FabricClientProxy.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index 3b3b0d8a9..18125a2c1 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -235,6 +235,11 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy ); }); + // TODO remove, just for testing + #if MC_VER == MC_1_17 + break compiling for test + #else + // Debug keyboard event // FIXME: Use better hooks so it doesn't trigger key press events in text boxes ClientTickEvents.END_CLIENT_TICK.register(client -> From f874219a64de0eeb0772b732e16bab1c570b69b6 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 13 Aug 2024 07:33:39 -0500 Subject: [PATCH 09/19] Wrong 1.17.1 perpreocessor used --- .../com/seibel/distanthorizons/fabric/FabricClientProxy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index 18125a2c1..e18d58d19 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -236,7 +236,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy }); // TODO remove, just for testing - #if MC_VER == MC_1_17 + #if MC_VER == MC_1_17_1 break compiling for test #else From e6b93e0d92fa682793da332ffd24ce0f594b2c46 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 13 Aug 2024 07:46:49 -0500 Subject: [PATCH 10/19] forgot to close test preprocessor --- .../com/seibel/distanthorizons/fabric/FabricClientProxy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index e18d58d19..8cd24c3ce 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -238,7 +238,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy // TODO remove, just for testing #if MC_VER == MC_1_17_1 break compiling for test - #else + #endif // Debug keyboard event // FIXME: Use better hooks so it doesn't trigger key press events in text boxes From 64da6c811d102ae7fbacd1634b3417b9c9995d24 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 13 Aug 2024 17:24:18 -0500 Subject: [PATCH 11/19] revert temporary 1.17.1 breakage --- .../com/seibel/distanthorizons/fabric/FabricClientProxy.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index 8cd24c3ce..fef9f927c 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -234,11 +234,6 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy #endif ); }); - - // TODO remove, just for testing - #if MC_VER == MC_1_17_1 - break compiling for test - #endif // Debug keyboard event // FIXME: Use better hooks so it doesn't trigger key press events in text boxes From 2a9136b56f0310e283a51f93d2f91cf9917bfd8f Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 15 Aug 2024 07:21:19 -0500 Subject: [PATCH 12/19] Merge 1.21.1 and 1.21 --- .../common/wrappers/block/BiomeWrapper.java | 2 +- .../wrappers/block/BlockStateWrapper.java | 2 +- .../common/wrappers/chunk/ChunkWrapper.java | 2 +- .../common/wrappers/gui/ClassicConfigGUI.java | 2 +- .../wrappers/gui/updater/UpdateModScreen.java | 4 +- .../MinecraftDedicatedServerWrapper.java | 2 +- .../minecraft/MinecraftRenderWrapper.java | 2 +- .../mimicObject/ChunkLoader.java | 4 +- .../mimicObject/DhGenerationChunkHolder.java | 2 +- .../mimicObject/DhLitWorldGenRegion.java | 4 +- .../worldGeneration/step/StepBiomes.java | 4 +- .../worldGeneration/step/StepFeatures.java | 2 +- .../worldGeneration/step/StepNoise.java | 4 +- .../step/StepStructureReference.java | 2 +- .../step/StepStructureStart.java | 2 +- .../worldGeneration/step/StepSurface.java | 2 +- .../fabric/FabricClientProxy.java | 2 +- .../mixins/client/MixinLevelRenderer.java | 2 +- .../mixins/client/MixinOptionsScreen.java | 4 +- .../wrappers/modAccessor/BCLibAccessor.java | 2 +- .../mixins/client/MixinLevelRenderer.java | 2 +- .../mixins/client/MixinOptionsScreen.java | 4 +- versionProperties/1.21.1.properties | 2 +- versionProperties/1.21.properties | 53 ------------------- 24 files changed, 30 insertions(+), 83 deletions(-) delete mode 100644 versionProperties/1.21.properties diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 5f1b205b0..a6ce51072 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -293,7 +293,7 @@ public class BiomeWrapper implements IBiomeWrapper ResourceLocation resourceLocation; try { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 resourceLocation = new ResourceLocation(resourceLocationString.substring(0, separatorIndex), resourceLocationString.substring(separatorIndex + 1)); #else resourceLocation = ResourceLocation.fromNamespaceAndPath(resourceLocationString.substring(0, separatorIndex), resourceLocationString.substring(separatorIndex + 1)); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 427386891..126818de9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -498,7 +498,7 @@ public class BlockStateWrapper implements IBlockStateWrapper ResourceLocation resourceLocation; try { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 resourceLocation = new ResourceLocation(resourceStateString.substring(0, separatorIndex), resourceStateString.substring(separatorIndex + 1)); #else resourceLocation = ResourceLocation.fromNamespaceAndPath(resourceStateString.substring(0, separatorIndex), resourceStateString.substring(separatorIndex + 1)); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index efad9cc73..26a4124c9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -305,7 +305,7 @@ public class ChunkWrapper implements IChunkWrapper public ChunkStatus getStatus() { return getStatus(this.getChunk()); } public static ChunkStatus getStatus(ChunkAccess chunk) { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 return chunk.getStatus(); #else return chunk.getPersistedStatus(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 2ca6c27a0..ae0ac876a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -259,7 +259,7 @@ public class ClassicConfigGUI 0, 0, // Some textuary stuff 0, - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), #else ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/changelog.png"), diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java index f4d52e9d6..198efe1a8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java @@ -76,7 +76,7 @@ public class UpdateModScreen extends DhScreen 0, 0, // Some textuary stuff 0, - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 new ResourceLocation(ModInfo.ID, "logo.png"), #else ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "logo.png"), @@ -107,7 +107,7 @@ public class UpdateModScreen extends DhScreen 0, 0, // Some textuary stuff 0, - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), #else ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/changelog.png"), diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java index bf09dc1bd..3439c34fc 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftDedicatedServerWrapper.java @@ -21,7 +21,7 @@ public class MinecraftDedicatedServerWrapper implements IMinecraftSharedWrapper throw new IllegalStateException("Trying to get Installation Direction before Dedicated server complete initialization!"); } - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 return this.dedicatedServer.getServerDirectory(); #else return this.dedicatedServer.getServerDirectory().toFile(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index 5d0ada3d8..defdf0103 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -165,7 +165,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper if (MC.level.dimensionType().hasSkyLight()) { float frameTime; - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 frameTime = MC.getFrameTime(); #else frameTime = MC.getTimer().getRealtimeDeltaTicks(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index 6e98738a6..1a3f77e3f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -85,7 +85,7 @@ import net.minecraft.world.level.material.Fluids; #if MC_VER == MC_1_20_6 import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.chunk.status.ChunkType; -#elif MC_VER >= MC_1_21 +#elif MC_VER >= MC_1_21_1 import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.chunk.status.ChunkType; #endif @@ -325,7 +325,7 @@ public class ChunkLoader } private static #if MC_VER < MC_1_20_6 ChunkStatus.ChunkType - #elif MC_VER < MC_1_21 ChunkType + #elif MC_VER < MC_1_21_1 ChunkType #else ChunkType #endif readChunkType(CompoundTag tagLevel) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java index 519938ce8..62e3bec7d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhGenerationChunkHolder.java @@ -1,6 +1,6 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject; -#if MC_VER >= MC_1_21 +#if MC_VER >= MC_1_21_1 import net.minecraft.server.level.GenerationChunkHolder; import net.minecraft.world.level.ChunkPos; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java index 48b5a3fb7..1d9c76676 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java @@ -63,7 +63,7 @@ import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.status.*; #endif -#if MC_VER >= MC_1_21 +#if MC_VER >= MC_1_21_1 import net.minecraft.util.StaticCache2D; import com.google.common.collect.ImmutableList; import net.minecraft.server.level.GenerationChunkHolder; @@ -127,7 +127,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion { #if MC_VER == MC_1_16_5 super(serverLevel, chunkList); - #elif MC_VER < MC_1_21 + #elif MC_VER < MC_1_21_1 super(serverLevel, chunkList, chunkStatus, writeRadius); #else super(serverLevel, diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java index f3cf3302f..16d633031 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepBiomes.java @@ -68,7 +68,7 @@ public final class StepBiomes } else if (chunk instanceof ProtoChunk) { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 ((ProtoChunk) chunk).setStatus(STATUS); #else ((ProtoChunk) chunk).setPersistedStatus(STATUS); @@ -89,7 +89,7 @@ public final class StepBiomes #elif MC_VER < MC_1_19_4 chunk = this.environment.joinSync(this.environment.params.generator.createBiomes(this.environment.params.biomes, Runnable::run, this.environment.params.randomState, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); - #elif MC_VER < MC_1_21 + #elif MC_VER < MC_1_21_1 chunk = this.environment.joinSync(this.environment.params.generator.createBiomes(Runnable::run, this.environment.params.randomState, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java index 8d8bfb182..962dd8e15 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepFeatures.java @@ -66,7 +66,7 @@ public final class StepFeatures } else if (chunk instanceof ProtoChunk) { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 ((ProtoChunk) chunk).setStatus(STATUS); #else ((ProtoChunk) chunk).setPersistedStatus(STATUS); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java index 47b524cd5..a9c8d1a1e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepNoise.java @@ -68,7 +68,7 @@ public final class StepNoise continue; } - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 ((ProtoChunk) chunk).setStatus(STATUS); #else ((ProtoChunk) chunk).setPersistedStatus(STATUS); @@ -87,7 +87,7 @@ public final class StepNoise #elif MC_VER < MC_1_19_2 chunk = this.environment.joinSync(this.environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); - #elif MC_VER < MC_1_21 + #elif MC_VER < MC_1_21_1 chunk = this.environment.joinSync(this.environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion), this.environment.params.randomState, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); #else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java index c5dc640e8..f0479e3b3 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java @@ -66,7 +66,7 @@ public final class StepStructureReference } else if (chunk instanceof ProtoChunk) { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 ((ProtoChunk) chunk).setStatus(STATUS); #else ((ProtoChunk) chunk).setPersistedStatus(STATUS); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java index 5dcb57468..96f58c730 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java @@ -83,7 +83,7 @@ public final class StepStructureStart } else if (chunk instanceof ProtoChunk) { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 ((ProtoChunk) chunk).setStatus(STATUS); #else ((ProtoChunk) chunk).setPersistedStatus(STATUS); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java index 56b247783..f557fe124 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepSurface.java @@ -65,7 +65,7 @@ public final class StepSurface } else if (chunk instanceof ProtoChunk) { - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 ((ProtoChunk) chunk).setStatus(STATUS); #else ((ProtoChunk) chunk).setPersistedStatus(STATUS); diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index fef9f927c..792992a09 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -227,7 +227,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy this.clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()), modelViewMatrix, projectionMatrix, - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 renderContext.tickDelta() #else renderContext.tickCounter().getGameTimeDeltaTicks() diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java index 8b729e082..7ffc97bda 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java @@ -116,7 +116,7 @@ public class MixinLevelRenderer ClientApi.INSTANCE.renderDeferredLods(ClientLevelWrapper.getWrapper(this.level), mcModelViewMatrix, mcProjectionMatrix, - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 Minecraft.getInstance().getFrameTime() #else Minecraft.getInstance().getTimer().getRealtimeDeltaTicks() diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java index d638536f7..55f0368c4 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java @@ -45,7 +45,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Shadow; #endif -#if MC_VER < MC_1_21 +#if MC_VER < MC_1_21_1 import net.minecraft.client.gui.screens.OptionsScreen; #else import net.minecraft.client.gui.screens.options.OptionsScreen; @@ -64,7 +64,7 @@ public class MixinOptionsScreen extends Screen /** Texture used for the config opening button */ @Unique private static final ResourceLocation ICON_TEXTURE = - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 new ResourceLocation(ModInfo.ID, "textures/gui/button.png"); #else ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/button.png"); diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java index 06efa7741..6d4c2cc17 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/BCLibAccessor.java @@ -5,7 +5,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IBCLibAcces #elif MC_VER == MC_1_18_2 import ru.bclib.config.ClientConfig; import ru.bclib.config.Configs; -#elif MC_VER < MC_1_21 +#elif MC_VER < MC_1_21_1 import org.betterx.bclib.config.ClientConfig; import org.betterx.bclib.config.Configs; #endif diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java index 93e1a06a7..51042d645 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java @@ -120,7 +120,7 @@ public class MixinLevelRenderer float frameTime; - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 frameTime = Minecraft.getInstance().getFrameTime(); #else frameTime = Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(); diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java index b1a661e78..488984f06 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java @@ -45,7 +45,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Shadow; #endif -#if MC_VER < MC_1_21 +#if MC_VER < MC_1_21_1 import net.minecraft.client.gui.screens.OptionsScreen; #else import net.minecraft.client.gui.screens.options.OptionsScreen; @@ -64,7 +64,7 @@ public class MixinOptionsScreen extends Screen /** Texture used for the config opening button */ @Unique private static final ResourceLocation ICON_TEXTURE = - #if MC_VER < MC_1_21 + #if MC_VER < MC_1_21_1 new ResourceLocation(ModInfo.ID, "textures/gui/button.png"); #else ResourceLocation.fromNamespaceAndPath(ModInfo.ID, "textures/gui/button.png"); diff --git a/versionProperties/1.21.1.properties b/versionProperties/1.21.1.properties index 9a4da88c7..b8dc67fee 100644 --- a/versionProperties/1.21.1.properties +++ b/versionProperties/1.21.1.properties @@ -2,7 +2,7 @@ java_version=21 minecraft_version=1.21.1 parchment_version=1.20.6:2024.05.01 -compatible_minecraft_versions=["1.21.1"] +compatible_minecraft_versions=["1.21", "1.21.1"] accessWidenerVersion=1_20_6 builds_for=fabric,neoforge # forge is broken due to gradle/build script issues diff --git a/versionProperties/1.21.properties b/versionProperties/1.21.properties deleted file mode 100644 index c2c73633b..000000000 --- a/versionProperties/1.21.properties +++ /dev/null @@ -1,53 +0,0 @@ -# 1.21 version -java_version=21 -minecraft_version=1.21 -parchment_version=1.20.6:2024.05.01 -compatible_minecraft_versions=["1.21"] -accessWidenerVersion=1_20_6 -builds_for=fabric,neoforge -# forge is broken due to gradle/build script issues - -# Fabric loader -fabric_loader_version=0.15.11 -fabric_api_version=0.100.1+1.21 - # Fabric mod versions - modmenu_version=11.0.0-beta.1 - starlight_version_fabric= - phosphor_version_fabric= - lithium_version= - sodium_version=mc1.21-0.5.9 - iris_version=1.7.1+1.21 - bclib_version= - immersive_portals_version= - canvas_version= - - fabric_incompatibility_list={ "iris": "<=1.7.4" } - fabric_recommend_list={} - - # Fabric mod run - # 0 = Don't enable and don't run - # 1 = Can be referenced in code but doesn't run - # 2 = Can be referenced in code and runs in client - enable_starlight=0 - enable_phosphor=0 - enable_sodium=1 - enable_lithium=0 - enable_iris=1 - enable_bclib=0 - enable_immersive_portals=0 - enable_canvas=0 - -# (Neo)Forge loader -forge_version=50.0.19 -neoforge_version=21.0.4-beta - # (Neo)Forge mod versions - starlight_version_forge= - terraforged_version= - - # (Neo)Forge mod run - # 0 = Don't enable and don't run - # 1 = Can be referenced in code but doesn't run - # 2 = Can be referenced in code and runs in client - enable_starlight_forge=0 - enable_terraforged=0 - enable_terrafirmacraft=0 From 8af61041f078ed594b6322b0bf2564fb308ce488 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 16 Aug 2024 17:28:36 -0500 Subject: [PATCH 13/19] Remove 1.21 from CI build script 1.21.1 also covers 1.21 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 56aedf4af..6f4eadabc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ build: stage: build parallel: matrix: - - MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4", "1.20.6", "1.21", "1.21.1"] + - MC_VER: ["1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.4", "1.20.1", "1.20.2", "1.20.4", "1.20.6", "1.21.1"] script: # this both runs the unit tests and assembles the code - ./gradlew clean -PmcVer="${MC_VER}" -PinfoGitCommit="${CI_COMMIT_SHA}" -PinfoGitBranch="${CI_COMMIT_BRANCH}" -PinfoBuildSource="GitLab CI (${CI_PIPELINE_ID})" --gradle-user-home cache/; From 82ff59c857535e2a4fc15fe4f7a54f94c0c201c7 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 17 Aug 2024 22:29:42 -0500 Subject: [PATCH 14/19] Fix fog and SSAO being broken by some mods --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 2cf952fb7..e68d0d5c4 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 2cf952fb768e38567698c8d58c80d328b7685a08 +Subproject commit e68d0d5c45498bedbe6c1adba8d27f3b552d12e6 From f5651f26a5335ead7e699f0a023a48e29d8c6dd4 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 18 Aug 2024 14:31:24 -0500 Subject: [PATCH 15/19] Merge !65 (fix neo/forge chunk update events) --- coreSubProjects | 2 +- .../fabric/FabricClientProxy.java | 15 +-- .../fabric/mixins/server/MixinChunkMap.java | 12 ++- .../forge/ForgeClientProxy.java | 101 +++++++++--------- .../forge/ForgeServerProxy.java | 8 -- .../forge/mixins/server/MixinChunkMap.java | 96 +++++++++++++++++ .../DistantHorizons.forge.mixins.json | 3 +- .../neoforge/NeoforgeClientProxy.java | 92 ++++++++-------- .../neoforge/NeoforgeServerProxy.java | 8 -- .../neoforge/mixins/server/MixinChunkMap.java | 97 +++++++++++++++++ .../DistantHorizons.neoforge.mixins.json | 3 +- 11 files changed, 304 insertions(+), 133 deletions(-) create mode 100644 forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java create mode 100644 neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java diff --git a/coreSubProjects b/coreSubProjects index e68d0d5c4..301cce3d1 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit e68d0d5c45498bedbe6c1adba8d27f3b552d12e6 +Subproject commit 301cce3d119e39c3902faf367cb55c71b7180dc0 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index 792992a09..e3f3c35ef 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -117,8 +117,11 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy // ClientChunkLoadEvent ClientChunkEvents.CHUNK_LOAD.register((level, chunk) -> { - IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level); - SharedApi.INSTANCE.chunkLoadEvent(new ChunkWrapper(chunk, level, wrappedLevel), wrappedLevel); + if (MC.clientConnectedToDedicatedServer()) + { + IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level); + SharedApi.INSTANCE.chunkLoadEvent(new ChunkWrapper(chunk, level, wrappedLevel), wrappedLevel); + } }); // (kinda) block break event @@ -200,14 +203,6 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy }); - // Client Chunk Save - ClientChunkEvents.CHUNK_UNLOAD.register((level, chunk) -> - { - IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper(level); - SharedApi.INSTANCE.chunkUnloadEvent(new ChunkWrapper(chunk, level, wrappedLevel), wrappedLevel); - }); - - //==============// // render event // diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java index ffef0238c..add9abccc 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java @@ -3,6 +3,7 @@ package com.seibel.distanthorizons.fabric.mixins.server; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; import com.seibel.distanthorizons.core.api.internal.ServerApi; +import com.seibel.distanthorizons.core.api.internal.SharedApi; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; @@ -83,10 +84,13 @@ public class MixinChunkMap - ServerApi.INSTANCE.serverChunkSaveEvent( - new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)), - ServerLevelWrapper.getWrapper(this.level) - ); + if (!SharedApi.isChunkAtBlockPosAlreadyUpdating(chunk.getPos().getWorldPosition().getX(), chunk.getPos().getWorldPosition().getZ()) ) + { + ServerApi.INSTANCE.serverChunkSaveEvent( + new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)), + ServerLevelWrapper.getWrapper(this.level) + ); + } } } diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeClientProxy.java b/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeClientProxy.java index 6784ad8e6..252d1fbdf 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeClientProxy.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeClientProxy.java @@ -176,53 +176,59 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy @SubscribeEvent public void rightClickBlockEvent(PlayerInteractEvent.RightClickBlock event) { - if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) + if (MC.clientConnectedToDedicatedServer()) { - return; - } - - //LOGGER.trace("interact or block place event at blockPos: " + event.getPos()); - - #if MC_VER < MC_1_19_2 - LevelAccessor level = event.getWorld(); - #else - LevelAccessor level = event.getLevel(); - #endif - - ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); - if (executor != null) - { - executor.execute(() -> + if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) { - ChunkAccess chunk = level.getChunk(event.getPos()); - this.onBlockChangeEvent(level, chunk); - }); + return; + } + + //LOGGER.trace("interact or block place event at blockPos: " + event.getPos()); + + #if MC_VER < MC_1_19_2 + LevelAccessor level = event.getWorld(); + #else + LevelAccessor level = event.getLevel(); + #endif + + ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); + if (executor != null) + { + executor.execute(() -> + { + ChunkAccess chunk = level.getChunk(event.getPos()); + this.onBlockChangeEvent(level, chunk); + }); + } } } @SubscribeEvent public void leftClickBlockEvent(PlayerInteractEvent.LeftClickBlock event) { - if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) + if (MC.clientConnectedToDedicatedServer()) { - return; - } - - //LOGGER.trace("break or block attack at blockPos: " + event.getPos()); - - #if MC_VER < MC_1_19_2 - LevelAccessor level = event.getWorld(); - #else - LevelAccessor level = event.getLevel(); - #endif - - ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); - if (executor != null) - { - executor.execute(() -> + if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) { - ChunkAccess chunk = level.getChunk(event.getPos()); - this.onBlockChangeEvent(level, chunk); - }); + return; + } + + //LOGGER.trace("break or block attack at blockPos: " + event.getPos()); + + #if MC_VER < MC_1_19_2 + LevelAccessor level = event.getWorld(); + #else + LevelAccessor level = event.getLevel(); + #endif + + ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); + if (executor != null) + { + executor.execute(() -> + { + ChunkAccess chunk = level.getChunk(event.getPos()); + this.onBlockChangeEvent(level, chunk); + }); + } } } private void onBlockChangeEvent(LevelAccessor level, ChunkAccess chunk) @@ -230,21 +236,16 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(level); SharedApi.INSTANCE.chunkBlockChangedEvent(new ChunkWrapper(chunk, level, wrappedLevel), wrappedLevel); } - - + @SubscribeEvent public void clientChunkLoadEvent(ChunkEvent.Load event) { - ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(GetEventLevel(event)); - IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), wrappedLevel); - SharedApi.INSTANCE.chunkLoadEvent(chunk, wrappedLevel); - } - @SubscribeEvent - public void clientChunkUnloadEvent(ChunkEvent.Unload event) - { - ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(GetEventLevel(event)); - IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), wrappedLevel); - SharedApi.INSTANCE.chunkUnloadEvent(chunk, wrappedLevel); + if (MC.clientConnectedToDedicatedServer()) + { + ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(GetEventLevel(event)); + IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), wrappedLevel); + SharedApi.INSTANCE.chunkLoadEvent(chunk, wrappedLevel); + } } diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeServerProxy.java b/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeServerProxy.java index 0c9521e0c..1be3b415b 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeServerProxy.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/ForgeServerProxy.java @@ -137,14 +137,6 @@ public class ForgeServerProxy implements AbstractModInitializer.IEventProxy IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), levelWrapper); this.serverApi.serverChunkLoadEvent(chunk, levelWrapper); } - @SubscribeEvent - public void serverChunkSaveEvent(ChunkEvent.Unload event) - { - ILevelWrapper levelWrapper = ProxyUtil.getLevelWrapper(GetEventLevel(event)); - - IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), levelWrapper); - this.serverApi.serverChunkSaveEvent(chunk, levelWrapper); - } diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java new file mode 100644 index 000000000..92e0a4a0c --- /dev/null +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java @@ -0,0 +1,96 @@ +package com.seibel.distanthorizons.forge.mixins.server; + +import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; +import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; +import com.seibel.distanthorizons.core.api.internal.ServerApi; +import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.chunk.ChunkAccess; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ChunkMap.class) +public class MixinChunkMap +{ + + @Unique + private static final String CHUNK_SERIALIZER_WRITE + = "Lnet/minecraft/world/level/chunk/storage/ChunkSerializer;write(" + + "Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Lnet/minecraft/nbt/CompoundTag;"; + + @Shadow + @Final + ServerLevel level; + + // firing at INVOKE causes issues with C2ME and is probably unnecessary since we + // don't need the chunk(s) before MC has finished saving them + @Inject(method = "save", at = @At(value = "RETURN", target = CHUNK_SERIALIZER_WRITE)) + private void onChunkSave(ChunkAccess chunk, CallbackInfoReturnable ci) + { + // true means a chunk was saved to disk + if (ci.getReturnValue()) + { + // TODO is this validation necessary since we are checking above if + // the callback return value should state if the chunk was actually saved or not? + // Do we trust it to always be correct? + + //=====================================// + // corrupt/incomplete chunk validation // + //=====================================// + + // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) + // this logic should prevent that from happening + #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) + { + return; + } + #else + if (chunk.isUnsaved() || chunk.isUpgrading() || !chunk.isLightCorrect()) + { + return; + } + #endif + + + //==================// + // biome validation // + //==================// + + // some chunks may be missing their biomes, which cause issues when attempting to save them + #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + if (chunk.getBiomes() == null) + { + return; + } + #else + try + { + // this will throw an exception if the biomes aren't set up + chunk.getNoiseBiome(0,0,0); + } + catch (Exception e) + { + return; + } + #endif + + + + if (!SharedApi.isChunkAtBlockPosAlreadyUpdating(chunk.getPos().getWorldPosition().getX(), chunk.getPos().getWorldPosition().getZ()) ) + { + ServerApi.INSTANCE.serverChunkSaveEvent( + new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)), + ServerLevelWrapper.getWrapper(this.level) + ); + } + } + } + +} \ No newline at end of file diff --git a/forge/src/main/resources/DistantHorizons.forge.mixins.json b/forge/src/main/resources/DistantHorizons.forge.mixins.json index c7b69cbaf..439d030d5 100644 --- a/forge/src/main/resources/DistantHorizons.forge.mixins.json +++ b/forge/src/main/resources/DistantHorizons.forge.mixins.json @@ -5,7 +5,8 @@ "mixins": [ "server.MixinUtilBackgroundThread", "server.MixinChunkGenerator", - "server.MixinTFChunkGenerator" + "server.MixinTFChunkGenerator", + "server.MixinChunkMap" ], "client": [ "client.MixinClientPacketListener", diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java index e5dc92b42..88cec2806 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java @@ -63,6 +63,8 @@ import org.lwjgl.opengl.GL32; import net.neoforged.neoforge.event.TickEvent; #else import net.neoforged.neoforge.client.event.ClientTickEvent; + +import java.util.concurrent.ThreadPoolExecutor; #endif @@ -164,49 +166,55 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy @SubscribeEvent public void rightClickBlockEvent(PlayerInteractEvent.RightClickBlock event) { - if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) + if (MC.clientConnectedToDedicatedServer()) { - return; - } - - // executor to prevent locking up the render/event thread - // if the getChunk() takes longer than expected - // (which can be caused by certain mods) - var executor = ThreadPoolUtil.getFileHandlerExecutor(); - if (executor != null) - { - executor.execute(() -> + if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) { - //LOGGER.trace("interact or block place event at blockPos: " + event.getPos()); - - LevelAccessor level = event.getLevel(); - ChunkAccess chunk = level.getChunk(event.getPos()); - this.onBlockChangeEvent(level, chunk); - }); + return; + } + + // executor to prevent locking up the render/event thread + // if the getChunk() takes longer than expected + // (which can be caused by certain mods) + ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); + if (executor != null) + { + executor.execute(() -> + { + //LOGGER.trace("interact or block place event at blockPos: " + event.getPos()); + + LevelAccessor level = event.getLevel(); + ChunkAccess chunk = level.getChunk(event.getPos()); + this.onBlockChangeEvent(level, chunk); + }); + } } } @SubscribeEvent public void leftClickBlockEvent(PlayerInteractEvent.LeftClickBlock event) { - if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) + if (MC.clientConnectedToDedicatedServer()) { - return; - } - - // executor to prevent locking up the render/event thread - // if the getChunk() takes longer than expected - // (which can be caused by certain mods) - var executor = ThreadPoolUtil.getFileHandlerExecutor(); - if (executor != null) - { - executor.execute(() -> + if (SharedApi.isChunkAtBlockPosAlreadyUpdating(event.getPos().getX(), event.getPos().getZ())) { - //LOGGER.trace("break or block attack at blockPos: " + event.getPos()); - - LevelAccessor level = event.getLevel(); - ChunkAccess chunk = level.getChunk(event.getPos()); - this.onBlockChangeEvent(level, chunk); - }); + return; + } + + // executor to prevent locking up the render/event thread + // if the getChunk() takes longer than expected + // (which can be caused by certain mods) + ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); + if (executor != null) + { + executor.execute(() -> + { + //LOGGER.trace("break or block attack at blockPos: " + event.getPos()); + + LevelAccessor level = event.getLevel(); + ChunkAccess chunk = level.getChunk(event.getPos()); + this.onBlockChangeEvent(level, chunk); + }); + } } } private void onBlockChangeEvent(LevelAccessor level, ChunkAccess chunk) @@ -216,22 +224,6 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy } - @SubscribeEvent - public void clientChunkLoadEvent(ChunkEvent.Load event) - { - ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(GetEventLevel(event)); - IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), wrappedLevel); - SharedApi.INSTANCE.chunkLoadEvent(chunk, wrappedLevel); - } - @SubscribeEvent - public void clientChunkUnloadEvent(ChunkEvent.Unload event) - { - ILevelWrapper wrappedLevel = ProxyUtil.getLevelWrapper(GetEventLevel(event)); - IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), wrappedLevel); - SharedApi.INSTANCE.chunkUnloadEvent(chunk, wrappedLevel); - } - - //==============// // key bindings // diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeServerProxy.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeServerProxy.java index f7e7e366b..8b02e1779 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeServerProxy.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeServerProxy.java @@ -122,14 +122,6 @@ public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), levelWrapper); this.serverApi.serverChunkLoadEvent(chunk, levelWrapper); } - @SubscribeEvent - public void serverChunkSaveEvent(ChunkEvent.Unload event) - { - ILevelWrapper levelWrapper = ProxyUtil.getLevelWrapper(GetEventLevel(event)); - - IChunkWrapper chunk = new ChunkWrapper(event.getChunk(), GetEventLevel(event), levelWrapper); - this.serverApi.serverChunkSaveEvent(chunk, levelWrapper); - } diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java new file mode 100644 index 000000000..c3d22e4b9 --- /dev/null +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java @@ -0,0 +1,97 @@ +package com.seibel.distanthorizons.neoforge.mixins.server; + +import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; +import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; +import com.seibel.distanthorizons.core.api.internal.ServerApi; +import com.seibel.distanthorizons.core.api.internal.SharedApi; +import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.chunk.ChunkAccess; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ChunkMap.class) +public class MixinChunkMap +{ + + @Unique + private static final String CHUNK_SERIALIZER_WRITE + = "Lnet/minecraft/world/level/chunk/storage/ChunkSerializer;write(" + + "Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ChunkAccess;)" + + "Lnet/minecraft/nbt/CompoundTag;"; + + @Shadow + @Final + ServerLevel level; + + // firing at INVOKE causes issues with C2ME and is probably unnecessary since we + // don't need the chunk(s) before MC has finished saving them + @Inject(method = "save", at = @At(value = "RETURN", target = CHUNK_SERIALIZER_WRITE)) + private void onChunkSave(ChunkAccess chunk, CallbackInfoReturnable ci) + { + // true means a chunk was saved to disk + if (ci.getReturnValue()) + { + // TODO is this validation necessary since we are checking above if + // the callback return value should state if the chunk was actually saved or not? + // Do we trust it to always be correct? + + //=====================================// + // corrupt/incomplete chunk validation // + //=====================================// + + // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) + // this logic should prevent that from happening + #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) + { + return; + } + #else + if (chunk.isUnsaved() || chunk.isUpgrading() || !chunk.isLightCorrect()) + { + return; + } + #endif + + + //==================// + // biome validation // + //==================// + + // some chunks may be missing their biomes, which cause issues when attempting to save them + #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + if (chunk.getBiomes() == null) + { + return; + } + #else + try + { + // this will throw an exception if the biomes aren't set up + chunk.getNoiseBiome(0,0,0); + } + catch (Exception e) + { + return; + } + #endif + + + + if (!SharedApi.isChunkAtBlockPosAlreadyUpdating(chunk.getPos().getWorldPosition().getX(), chunk.getPos().getWorldPosition().getZ()) ) + { + ServerApi.INSTANCE.serverChunkSaveEvent( + new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)), + ServerLevelWrapper.getWrapper(this.level) + ); + } + } + } + +} \ No newline at end of file diff --git a/neoforge/src/main/resources/DistantHorizons.neoforge.mixins.json b/neoforge/src/main/resources/DistantHorizons.neoforge.mixins.json index 5efe0dba6..eb99ea742 100644 --- a/neoforge/src/main/resources/DistantHorizons.neoforge.mixins.json +++ b/neoforge/src/main/resources/DistantHorizons.neoforge.mixins.json @@ -5,7 +5,8 @@ "mixins": [ "server.MixinUtilBackgroundThread", "server.MixinChunkGenerator", - "server.MixinTFChunkGenerator" + "server.MixinTFChunkGenerator", + "server.MixinChunkMap" ], "client": [ "client.MixinClientPacketListener", From 16836a2b492a748c0df5acac7d8e10adeeb093d4 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 18 Aug 2024 14:46:49 -0500 Subject: [PATCH 16/19] Move MixinChunkMap shared code to common --- .../commonMixins/MixinChunkMapCommon.java | 85 +++++++++++++++++++ coreSubProjects | 2 +- .../fabric/mixins/server/MixinChunkMap.java | 66 +------------- .../forge/mixins/server/MixinChunkMap.java | 65 +------------- .../neoforge/mixins/server/MixinChunkMap.java | 66 +------------- 5 files changed, 92 insertions(+), 192 deletions(-) create mode 100644 common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java new file mode 100644 index 000000000..a9dce2530 --- /dev/null +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinChunkMapCommon.java @@ -0,0 +1,85 @@ +package com.seibel.distanthorizons.common.commonMixins; + +import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; +import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; +import com.seibel.distanthorizons.core.api.internal.ServerApi; +import com.seibel.distanthorizons.core.api.internal.SharedApi; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.chunk.ChunkAccess; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +public class MixinChunkMapCommon +{ + + public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable ci) + { + // is this position already being updated? + if (SharedApi.isChunkAtChunkPosAlreadyUpdating(chunk.getPos().x, chunk.getPos().z)) + { + return; + } + + + + // is this chunk being saved to disk? + boolean savingChunkToDisk = ci.getReturnValue(); + // true means a chunk was saved to disk + if (!savingChunkToDisk) + { + return; + } + + // TODO are the following validations necessary since we are checking above if + // the callback return value should state if the chunk was actually saved or not? + // Do we trust it to always be correct? + + + + // corrupt/incomplete chunk validation // + + // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) + // this logic should prevent that from happening + #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) + { + return; + } + #else + if (chunk.isUnsaved() || chunk.isUpgrading() || !chunk.isLightCorrect()) + { + return; + } + #endif + + + + // biome validation // + + // some chunks may be missing their biomes, which cause issues when attempting to save them + #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + if (chunk.getBiomes() == null) + { + return; + } + #else + try + { + // this will throw an exception if the biomes aren't set up + chunk.getNoiseBiome(0,0,0); + } + catch (Exception e) + { + return; + } + #endif + + + + // submit the update event + ServerApi.INSTANCE.serverChunkSaveEvent( + new ChunkWrapper(chunk, level, ServerLevelWrapper.getWrapper(level)), + ServerLevelWrapper.getWrapper(level) + ); + } + +} diff --git a/coreSubProjects b/coreSubProjects index 301cce3d1..1b162f10e 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 301cce3d119e39c3902faf367cb55c71b7180dc0 +Subproject commit 1b162f10e6a092f8915c26a19ba6e5233b0c52fa diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java index add9abccc..19ee18ee5 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/server/MixinChunkMap.java @@ -1,9 +1,6 @@ package com.seibel.distanthorizons.fabric.mixins.server; -import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; -import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; -import com.seibel.distanthorizons.core.api.internal.ServerApi; -import com.seibel.distanthorizons.core.api.internal.SharedApi; +import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; @@ -33,65 +30,6 @@ public class MixinChunkMap // don't need the chunk(s) before MC has finished saving them @Inject(method = "save", at = @At(value = "RETURN", target = CHUNK_SERIALIZER_WRITE)) private void onChunkSave(ChunkAccess chunk, CallbackInfoReturnable ci) - { - // true means a chunk was saved to disk - if (ci.getReturnValue()) - { - // TODO is this validation necessary since we are checking above if - // the callback return value should state if the chunk was actually saved or not? - // Do we trust it to always be correct? - - //=====================================// - // corrupt/incomplete chunk validation // - //=====================================// - - // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) - // this logic should prevent that from happening - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 - if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) - { - return; - } - #else - if (chunk.isUnsaved() || chunk.isUpgrading() || !chunk.isLightCorrect()) - { - return; - } - #endif - - - //==================// - // biome validation // - //==================// - - // some chunks may be missing their biomes, which cause issues when attempting to save them - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 - if (chunk.getBiomes() == null) - { - return; - } - #else - try - { - // this will throw an exception if the biomes aren't set up - chunk.getNoiseBiome(0,0,0); - } - catch (Exception e) - { - return; - } - #endif - - - - if (!SharedApi.isChunkAtBlockPosAlreadyUpdating(chunk.getPos().getWorldPosition().getX(), chunk.getPos().getWorldPosition().getZ()) ) - { - ServerApi.INSTANCE.serverChunkSaveEvent( - new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)), - ServerLevelWrapper.getWrapper(this.level) - ); - } - } - } + { MixinChunkMapCommon.onChunkSave(this.level, chunk, ci); } } diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java index 92e0a4a0c..4109ac6bd 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/server/MixinChunkMap.java @@ -1,8 +1,6 @@ package com.seibel.distanthorizons.forge.mixins.server; -import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; -import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; -import com.seibel.distanthorizons.core.api.internal.ServerApi; +import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; @@ -32,65 +30,6 @@ public class MixinChunkMap // don't need the chunk(s) before MC has finished saving them @Inject(method = "save", at = @At(value = "RETURN", target = CHUNK_SERIALIZER_WRITE)) private void onChunkSave(ChunkAccess chunk, CallbackInfoReturnable ci) - { - // true means a chunk was saved to disk - if (ci.getReturnValue()) - { - // TODO is this validation necessary since we are checking above if - // the callback return value should state if the chunk was actually saved or not? - // Do we trust it to always be correct? - - //=====================================// - // corrupt/incomplete chunk validation // - //=====================================// - - // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) - // this logic should prevent that from happening - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 - if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) - { - return; - } - #else - if (chunk.isUnsaved() || chunk.isUpgrading() || !chunk.isLightCorrect()) - { - return; - } - #endif - - - //==================// - // biome validation // - //==================// - - // some chunks may be missing their biomes, which cause issues when attempting to save them - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 - if (chunk.getBiomes() == null) - { - return; - } - #else - try - { - // this will throw an exception if the biomes aren't set up - chunk.getNoiseBiome(0,0,0); - } - catch (Exception e) - { - return; - } - #endif - - - - if (!SharedApi.isChunkAtBlockPosAlreadyUpdating(chunk.getPos().getWorldPosition().getX(), chunk.getPos().getWorldPosition().getZ()) ) - { - ServerApi.INSTANCE.serverChunkSaveEvent( - new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)), - ServerLevelWrapper.getWrapper(this.level) - ); - } - } - } + { MixinChunkMapCommon.onChunkSave(this.level, chunk, ci); } } \ No newline at end of file diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java index c3d22e4b9..9ecfce79d 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/server/MixinChunkMap.java @@ -1,9 +1,6 @@ package com.seibel.distanthorizons.neoforge.mixins.server; -import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; -import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; -import com.seibel.distanthorizons.core.api.internal.ServerApi; -import com.seibel.distanthorizons.core.api.internal.SharedApi; +import com.seibel.distanthorizons.common.commonMixins.MixinChunkMapCommon; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.ChunkAccess; @@ -33,65 +30,6 @@ public class MixinChunkMap // don't need the chunk(s) before MC has finished saving them @Inject(method = "save", at = @At(value = "RETURN", target = CHUNK_SERIALIZER_WRITE)) private void onChunkSave(ChunkAccess chunk, CallbackInfoReturnable ci) - { - // true means a chunk was saved to disk - if (ci.getReturnValue()) - { - // TODO is this validation necessary since we are checking above if - // the callback return value should state if the chunk was actually saved or not? - // Do we trust it to always be correct? - - //=====================================// - // corrupt/incomplete chunk validation // - //=====================================// - - // MC has a tendency to try saving incomplete or corrupted chunks (which show up as empty or black chunks) - // this logic should prevent that from happening - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 - if (chunk.isUnsaved() || chunk.getUpgradeData() != null || !chunk.isLightCorrect()) - { - return; - } - #else - if (chunk.isUnsaved() || chunk.isUpgrading() || !chunk.isLightCorrect()) - { - return; - } - #endif - - - //==================// - // biome validation // - //==================// - - // some chunks may be missing their biomes, which cause issues when attempting to save them - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 - if (chunk.getBiomes() == null) - { - return; - } - #else - try - { - // this will throw an exception if the biomes aren't set up - chunk.getNoiseBiome(0,0,0); - } - catch (Exception e) - { - return; - } - #endif - - - - if (!SharedApi.isChunkAtBlockPosAlreadyUpdating(chunk.getPos().getWorldPosition().getX(), chunk.getPos().getWorldPosition().getZ()) ) - { - ServerApi.INSTANCE.serverChunkSaveEvent( - new ChunkWrapper(chunk, this.level, ServerLevelWrapper.getWrapper(this.level)), - ServerLevelWrapper.getWrapper(this.level) - ); - } - } - } + { MixinChunkMapCommon.onChunkSave(this.level, chunk, ci); } } \ No newline at end of file From d62e50d6f47bc04817061de75cf927b9b9fd02f2 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 20 Aug 2024 17:45:31 -0500 Subject: [PATCH 17/19] Fix Legacy GL causing fog to smear --- coreSubProjects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreSubProjects b/coreSubProjects index 1b162f10e..e71e8d196 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 1b162f10e6a092f8915c26a19ba6e5233b0c52fa +Subproject commit e71e8d1966cd6cae3781d4983e560a198d4e5e53 From 89b959d3f514609b1488455ec7e8fbadd671c518 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 20 Aug 2024 17:45:42 -0500 Subject: [PATCH 18/19] Up version number 2.1.3-dev -> 2.2.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c0fd0ff24..0f2936aa7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.caching=true # Mod Info mod_name=DistantHorizons -mod_version=2.1.3-a-dev +mod_version=2.2.0-a api_version=3.0.0 maven_group=com.seibel.distanthorizons mod_readable_name=Distant Horizons From 3875c8c4cef69cf873ff203cdc6c8d277df535ef Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 20 Aug 2024 19:16:28 -0500 Subject: [PATCH 19/19] Up version number 2.2.0 -> 2.2.1-dev --- coreSubProjects | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index e71e8d196..48d1005be 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit e71e8d1966cd6cae3781d4983e560a198d4e5e53 +Subproject commit 48d1005be6b6c323bf1de6a2775f920423bf4ce8 diff --git a/gradle.properties b/gradle.properties index 0f2936aa7..d100253ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.caching=true # Mod Info mod_name=DistantHorizons -mod_version=2.2.0-a +mod_version=2.2.1-a-dev api_version=3.0.0 maven_group=com.seibel.distanthorizons mod_readable_name=Distant Horizons