diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4c8068a2b..ce9ce5eef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,9 +3,10 @@ image: gradle:eclipse-temurin # all stages need to be defined here stages: - - build_17_1 - - build_18_1 - build_18_2 + - build_18_1 + - build_17_1 + - build_16_5 variables: # Pull core when building @@ -19,6 +20,26 @@ before_script: +# 1.16.5 build +build_16_5: + stage: build_16_5 + script: + - ./gradlew deleteMerged --gradle-user-home cache/; + - ./gradlew build -PmcVer=1.16.5 --gradle-user-home cache/; + - ./gradlew merge --gradle-user-home cache/; + image: eclipse-temurin:8 + artifacts: + name: "Merged_NightlyBuild_1_16_5-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" + paths: + - Merged + expire_in: 1 day + cache: + key: "gradleCache" + policy: pull-push + paths: + - .gradle + - cache/ + # 1.17.1 build build_17_1: stage: build_17_1 diff --git a/1.16.5.properties b/1.16.5.properties new file mode 100644 index 000000000..2abaa393f --- /dev/null +++ b/1.16.5.properties @@ -0,0 +1,40 @@ +# 1.16.5 version + +java_version=8 +minecraft_version=1.16.5 +compatible_minecraft_versions=["1.16.4", "1.16.5"] + +# Fabric loader +fabric_loader_version=0.13.2 +fabric_api_version=0.42.0+1.16 + # Fabric mod versions + modmenu_version=1.16.22 + starlight_version_fabric= + phosphor_version_fabric= + lithium_version=mc1.16.5-0.6.6 + sodium_version=3488820 + iris_version=1.16.x-v1.1.4 + bclib_version= + immersive_portals_version = + + # Fabric mod run + # 0 = Dont enable and dont run + # 1 = Can be refranced in code but dosnt run + # 2 = Can be refranced in code and runs in client + enable_starlight=0 + enable_phosphor=0 + enable_lithium=0 + enable_sodium=1 + enable_iris=0 + enable_bclib=0 + +# Forge loader +forge_version=36.2.28 + # Forge mod versions + starlight_version_forge= + + # Forge mod run + # 0 = Dont enable and dont run + # 1 = Can be refranced in code but dosnt run + # 2 = Can be refranced in code and runs in client + enable_starlight_forge=0 diff --git a/1.17.1.properties b/1.17.1.properties index 653c8e4c3..3cbe7f17a 100644 --- a/1.17.1.properties +++ b/1.17.1.properties @@ -1,7 +1,8 @@ # 1.17.1 version +java_version=16 minecraft_version=1.17.1 -java_version=17 +compatible_minecraft_versions=["1.17", "1.17.1"] # Fabric loader fabric_loader_version=0.13.2 diff --git a/1.18.1.properties b/1.18.1.properties index 6c4d8be27..71bbd4277 100644 --- a/1.18.1.properties +++ b/1.18.1.properties @@ -1,7 +1,8 @@ # 1.18.1 version -minecraft_version=1.18.1 java_version = 17 +minecraft_version=1.18.1 +compatible_minecraft_versions=["1.18", "1.18.1"] # Fabric loader fabric_loader_version=0.13.3 diff --git a/1.18.2.properties b/1.18.2.properties index 718b92c06..73cb48d53 100644 --- a/1.18.2.properties +++ b/1.18.2.properties @@ -1,8 +1,8 @@ # 1.18.2 version based stuff -# architectury_plugin_version = 3.4-SNAPSHOT -# dev_architectury_loom_version = 0.10.0-SNAPSHOT -minecraft_version=1.18.2 + java_version = 17 +minecraft_version=1.18.2 +compatible_minecraft_versions=["1.18.2"] # Fabric loader fabric_loader_version=0.13.3 diff --git a/build.gradle b/build.gradle index 5459d5861..0e83a4bdf 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,7 @@ def loadProperties() { writeBuildGradlePredefine() def mcVersionToAcsessWidenerVersion = [ + "1_16_5": "1_16", "1.17.1": "1_17", "1.18.1": "1_18", "1.18.2": "1_18" @@ -51,6 +52,15 @@ architectury { minecraft = rootProject.minecraft_version } +// Stuff for access wideners +def mcVersionToAcsessWidenerVersion = [ + "1_16_5": "1_16", + "1_17_1": "1_17", + "1_18_1": "1_18", + "1_18_2": "1_18" +] // Use this as sometimes multiple versions use the same access wideners +def acsessWidenerVersion = mcVersionToAcsessWidenerVersion.get(minecraft_version.replace(".", "_")) + subprojects { p -> apply plugin: "dev.architectury.loom" @@ -58,7 +68,7 @@ subprojects { p -> silentMojangMappingsLicense() if (p != project(":core")) { - accessWidenerPath.set(project(":common").file("/src/main/resources/${acsessWidenerVersion}.lod.accesswidener")) + accessWidenerPath.set(project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener")) } } @@ -164,6 +174,7 @@ allprojects { p -> source: mod_source, issues: mod_issues, minecraft_version: minecraft_version, + compatible_minecraft_versions: compatible_minecraft_versions, java_version: java_version ] // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties //TODO: Make Forge loader version also be relaced with non hardcoded value instead of "[36,41)" @@ -228,18 +239,6 @@ allprojects { p -> runClient.enabled = false runServer.enabled = false } - - - // this is necessary for running the fabric build - if (p == project(":common")) { - println "Copying [common/src/main/resources/${acsessWidenerVersion}.lod.accesswidner] to [fabric/build/resources/main]." - - copy { - from project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener") - into "$rootProject.rootDir/fabric/build/resources/main" - rename "${acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" - } - } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java index f44b8ff41..0fe94bf8b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java @@ -14,7 +14,9 @@ import com.seibel.lod.common.wrappers.world.BiomeWrapper; import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion; import net.minecraft.core.BlockPos; +#if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 import net.minecraft.core.QuartPos; +#endif import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.block.LiquidBlockContainer; @@ -45,13 +47,21 @@ public class ChunkWrapper implements IChunkWrapper @Override public int getHeight(){ + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 return chunk.getHeight(); + #elif MC_VERSION_1_16_5 + return 255; + #endif } @Override public int getMinBuildHeight() { + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 return chunk.getMinBuildHeight(); + #elif MC_VERSION_1_16_5 + return 0; + #endif } @Override public int getMaxBuildHeight() @@ -77,6 +87,9 @@ public class ChunkWrapper implements IChunkWrapper #elif MC_VERSION_1_17_1 return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome( QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); + #elif MC_VERSION_1_16_5 + return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome( + x >> 2, y >> 2, z >> 2)); #endif } @@ -157,7 +170,7 @@ public class ChunkWrapper implements IChunkWrapper @Override public boolean isLightCorrect(){ - #if MC_VERSION_1_17_1 + #if MC_VERSION_1_16_5 || MC_VERSION_1_17_1 return true; #elif MC_VERSION_1_18_2 || MC_VERSION_1_18_1 if (chunk instanceof LevelChunk) { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java index ff230ac63..dc1d482ef 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java @@ -50,7 +50,9 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.client.resources.language.I18n; // translation -import net.minecraft.client.gui.narration.NarratableEntry; // Remove in 1.16 +#if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 +import net.minecraft.client.gui.narration.NarratableEntry; +#endif /** * Based upon TinyConfig @@ -537,15 +539,29 @@ public abstract class ConfigGui // addRenderableWidget in 1.17 and over // addButton in 1.16 and below + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 this.addRenderableWidget(new Button(this.width / 2 - 154, this.height - 28, 150, 20, CommonComponents.GUI_CANCEL, button -> { loadFromFile(); Objects.requireNonNull(minecraft).setScreen(parent); })); + #elif MC_VERSION_1_16_5 + this.addButton(new Button(this.width / 2 - 154, this.height - 28, 150, 20, CommonComponents.GUI_CANCEL, button -> { + loadFromFile(); + Objects.requireNonNull(minecraft).setScreen(parent); + })); + #endif + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 Button done = this.addRenderableWidget(new Button(this.width / 2 + 4, this.height - 28, 150, 20, CommonComponents.GUI_DONE, (button) -> { saveToFile(); Objects.requireNonNull(minecraft).setScreen(parent); })); + #elif MC_VERSION_1_16_5 + Button done = this.addButton(new Button(this.width / 2 + 4, this.height - 28, 150, 20, CommonComponents.GUI_DONE, (button) -> { + saveToFile(); + Objects.requireNonNull(minecraft).setScreen(parent); + })); + #endif this.list = new ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, this.height - 32, 25); if (this.minecraft != null && this.minecraft.level != null) @@ -753,10 +769,12 @@ public abstract class ConfigGui // Only for 1.17 and over // Remove in 1.16 and below + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 @Override public List narratables() { return children; } + #endif } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java index db3d70353..38f90b0ac 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -42,9 +42,15 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; +#if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 import net.minecraft.world.level.material.FogType; +#elif MC_VERSION_1_16_5 +import net.minecraft.tags.FluidTags; +import net.minecraft.world.level.material.FluidState; +#endif import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import org.lwjgl.opengl.GL15; /** @@ -96,7 +102,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Mat4f getDefaultProjectionMatrix(float partialTicks) { + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true))); + #elif MC_VERSION_1_16_5 + return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getMainCamera(), partialTicks, true)); + #endif } @Override @@ -107,8 +117,13 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Color getFogColor(float partialTicks) { + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks)); float[] colorValues = RenderSystem.getShaderFogColor(); + #elif MC_VERSION_1_16_5 + float[] colorValues = new float[4]; + GL15.glGetFloatv(GL15.GL_FOG_COLOR, colorValues); + #endif return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]); } // getSpecialFogColor() is the same as getFogColor() @@ -116,7 +131,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public Color getSkyColor() { if (MC.level.dimensionType().hasSkyLight()) { + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime()); + #elif MC_VERSION_1_16_5 + Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getBlockPosition(), MC.getFrameTime()); + #endif return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); } else return new Color(0, 0, 0); @@ -134,7 +153,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 return MC.options.getEffectiveRenderDistance(); - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 return MC.options.renderDistance; #endif } @@ -198,19 +217,19 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper LevelRenderer levelRenderer = MC.levelRenderer; #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 ObjectArrayList chunks = levelRenderer.renderChunks; #endif return (chunks.stream().map((chunk) -> { #if MC_VERSION_1_18_2 AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); - #elif MC_VERSION_1_17_1 || MC_VERSION_1_18_1 + #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 || MC_VERSION_1_18_1 AABB chunkBoundingBox = chunk.chunk.bb; #endif #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), Math.floorDiv((int) chunkBoundingBox.minZ, 16)); - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), Math.floorDiv((int) chunkBoundingBox.minZ, 16)); #endif @@ -337,9 +356,19 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public boolean isFogStateSpecial() { + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 Entity entity = GAME_RENDERER.getMainCamera().getEntity(); boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS); return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind; + #elif MC_VERSION_1_16_5 + Camera camera = GAME_RENDERER.getMainCamera(); + FluidState fluidState = camera.getFluidInCamera(); + Entity entity = camera.getEntity(); + boolean isUnderWater = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS); + isUnderWater |= fluidState.is(FluidTags.WATER); + isUnderWater |= fluidState.is(FluidTags.LAVA); + return isUnderWater; + #endif } @Override diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java index 381712d9c..595db132f 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java @@ -18,8 +18,8 @@ public final class ThreadedParameters #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 public WorldGenStructFeatManager structFeat = null; public final StructureCheck structCheck; - #elif MC_VERSION_1_17_1 - public WorldGenStructFeatManager structFeat = null; + #elif MC_VERSION_1_17_1 || MC_VERSION_1_16_5 + public WorldGenStructFeatManager structFeat; #endif boolean isValid = true; public final PerfCalculator perf = new PerfCalculator(); @@ -46,7 +46,7 @@ public final class ThreadedParameters structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures, param.level.dimension(), param.generator, level, param.generator.getBiomeSource(), param.worldSeed, param.fixerUpper); - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_17_1 || MC_VERSION_1_16_5 level = param.level; structFeat = new WorldGenStructFeatManager(param.worldGenSettings, level); #endif diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java index 7a272233a..fe9b570af 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java @@ -4,7 +4,9 @@ import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor; import net.minecraft.world.level.BlockGetter; +#if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 import net.minecraft.world.level.LevelHeightAccessor; +#endif import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LightChunkGetter; @@ -34,7 +36,10 @@ public class LightGetterAdaptor implements LightChunkGetter { public BlockGetter getLevel() { return shouldReturnNull ? null : (genRegion != null ? genRegion : heightGetter); } + + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 public LevelHeightAccessor getLevelHeightAccessor() { return heightGetter; } + #endif } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java index e115ed82a..8575d3c19 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java @@ -23,7 +23,9 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ColorResolver; +#if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 import net.minecraft.world.level.LevelHeightAccessor; +#endif import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.StructureFeatureManager; import net.minecraft.world.level.biome.Biome; @@ -61,7 +63,11 @@ public class LightedWorldGenRegion extends WorldGenRegion { public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine, List list, ChunkStatus chunkStatus, int i, LightGenerationMode lightMode, EmptyChunkGenerator generator) { + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 super(serverLevel, list, chunkStatus, i); + #elif MC_VERSION_1_16_5 + super(serverLevel, list); + #endif this.lightMode = lightMode; this.firstPos = list.get(0).getPos(); this.generator = generator; @@ -71,6 +77,7 @@ public class LightedWorldGenRegion extends WorldGenRegion { size = Mth.floor(Math.sqrt(list.size())); } + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 // Bypass BCLib mixin overrides. @Override public boolean ensureCanWrite(BlockPos blockPos) { @@ -93,6 +100,7 @@ public class LightedWorldGenRegion extends WorldGenRegion { #endif return true; } + #endif // TODO Check this // @Override diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java index 0990f18c2..acbca3b30 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java @@ -5,7 +5,9 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; import net.minecraft.world.level.ChunkPos; +#if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 import net.minecraft.world.level.LevelHeightAccessor; +#endif import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.DataLayer; @@ -18,7 +20,9 @@ import net.minecraft.world.level.lighting.SkyLightEngine; public class WorldGenLevelLightEngine extends LevelLightEngine { public static final int MAX_SOURCE_LEVEL = 15; public static final int LIGHT_SECTION_PADDING = 1; + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 protected final LevelHeightAccessor levelHeightAccessor; + #endif @Nullable public final BlockLightEngine blockEngine; @Nullable @@ -26,7 +30,9 @@ public class WorldGenLevelLightEngine extends LevelLightEngine { public WorldGenLevelLightEngine(LightGetterAdaptor genRegion) { super(genRegion, false, false); + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 this.levelHeightAccessor = genRegion.getLevelHeightAccessor(); + #endif this.blockEngine = new BlockLightEngine(genRegion); this.skyEngine = new SkyLightEngine(genRegion); } @@ -123,9 +129,19 @@ public class WorldGenLevelLightEngine extends LevelLightEngine { chunkAccess.setLightCorrect(false); LevelChunkSection[] levelChunkSections = chunkAccess.getSections(); - for (int i = 0; i < chunkAccess.getSectionsCount(); ++i) { + for (int i = 0; i < + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 + chunkAccess.getSectionsCount() + #elif MC_VERSION_1_16_5 + 16 + #endif + ; ++i) { LevelChunkSection levelChunkSection = levelChunkSections[i]; - #if MC_VERSION_1_17_1 + #if MC_VERSION_1_16_5 + if (!LevelChunkSection.isEmpty(levelChunkSection)) { + updateSectionStatus(SectionPos.of(chunkPos, i), false); + } + #elif MC_VERSION_1_17_1 if (!LevelChunkSection.isEmpty(levelChunkSection)) { int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i); updateSectionStatus(SectionPos.of(chunkPos, j), false); @@ -139,9 +155,9 @@ public class WorldGenLevelLightEngine extends LevelLightEngine { enableLightSources(chunkPos, true); if (needLightBlockUpdate) { chunkAccess.getLights().forEach(blockPos -> - onBlockEmissionIncrease(blockPos, chunkAccess.getLightEmission(blockPos))); + onBlockEmissionIncrease(blockPos, chunkAccess.getLightEmission(blockPos))); } - + chunkAccess.setLightCorrect(true); } @@ -168,6 +184,8 @@ public class WorldGenLevelLightEngine extends LevelLightEngine { this.skyEngine.retainData(chunkPos, bl); } } + + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 @Override public int getLightSectionCount() { throw new UnsupportedOperationException("This should never be used!"); @@ -180,4 +198,5 @@ public class WorldGenLevelLightEngine extends LevelLightEngine { public int getMaxLightSection() { throw new UnsupportedOperationException("This should never be used!"); } + #endif } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java index 78906be3f..b65140232 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Objects; import java.util.function.Consumer; import java.util.function.Predicate; +import java.util.stream.Collectors; import java.util.stream.Stream; import com.google.common.collect.ImmutableList; @@ -41,7 +42,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { this.genLevel = genLevel; this.worldGenSettings = worldGenSettings; } - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_17_1 || MC_VERSION_1_16_5 public WorldGenStructFeatManager(WorldGenSettings worldGenSettings, WorldGenLevel genLevel) { @@ -99,7 +100,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { StructureFeature structureFeature) { ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES); - if (chunk == null) return List.of(); + if (chunk == null) return (List) Stream.empty(); // Copied from StructureFeatureManager::startsForFeature(...) with slight tweaks LongSet longSet = chunk.getReferencesForFeature(structureFeature); @@ -121,7 +122,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { @Override public List startsForFeature(SectionPos sectionPos, Predicate> predicate) { ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES); - if (chunk == null) return List.of(); + if (chunk == null) return (List) Stream.empty(); // Copied from StructureFeatureManager::startsForFeature(...) Map, LongSet> map = chunk.getAllReferences(); @@ -145,7 +146,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { @Override public List startsForFeature(SectionPos sectionPos, ConfiguredStructureFeature configuredStructureFeature) { ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES); - if (chunk == null) return List.of(); + if (chunk == null) return (List) Stream.empty(); // Copied from StructureFeatureManager::startsForFeature(...) LongSet longSet = chunk.getReferencesForFeature(configuredStructureFeature); @@ -159,7 +160,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { public Map, LongSet> getAllStructuresAt(BlockPos blockPos) { SectionPos sectionPos = SectionPos.of(blockPos); ChunkAccess chunk = _getChunk(sectionPos.x(), sectionPos.z(), ChunkStatus.STRUCTURE_REFERENCES); - if (chunk == null) return Map.of(); + if (chunk == null) return (Map, LongSet>) Stream.empty(); return chunk.getAllReferences(); } #endif diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java index 62f5171d2..2e168f2ab 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepNoise.java @@ -11,7 +11,9 @@ import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters; import net.minecraft.server.level.WorldGenRegion; import net.minecraft.util.Mth; +#if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 || MC_VERSION_1_17_1 import net.minecraft.world.level.LevelHeightAccessor; +#endif import net.minecraft.world.level.StructureFeatureManager; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; @@ -58,6 +60,8 @@ public final class StepNoise { #elif MC_VERSION_1_17_1 chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk)); + #elif MC_VERSION_1_16_5 + environment.params.generator.fillFromNoise(worldGenRegion, tParams.structFeat, chunk); #endif } } diff --git a/common/src/main/resources/1_16.lod.accesswidener b/common/src/main/resources/1_16.lod.accesswidener new file mode 100644 index 000000000..c65b3a27e --- /dev/null +++ b/common/src/main/resources/1_16.lod.accesswidener @@ -0,0 +1,47 @@ +accessWidener v1 named + +# used when determining where to save files to +accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File; + +# used when rendering +accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I +accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I +accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D + +# pre-render setup +accessible field net/minecraft/client/renderer/LevelRenderer renderChunks Lit/unimi/dsi/fastutil/objects/ObjectArrayList; +accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo +accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk; + +# used for grabbing vanilla rendered chunks +accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo +accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk; + +# lighting +accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage; +accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture; +accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine; +accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine; + +# world generation +accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V +accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings; +accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory; +# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder; +#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V +accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V + +# lod generation from save file +accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop; +accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag; + + +# grabbing textures +accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite animatedTexture Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture; +accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite width I +accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite height I +accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage; +accessible class net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture +accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameX (I)I +accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameY (I)I +extendable class com/mojang/math/Matrix4f \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index f67d3e452..6472ededc 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "${mod_name}", "description": "${description}", - "authors": ["${authors}"], + "authors": ${authors}, "contact": { "homepage": "${homepage}", @@ -36,12 +36,9 @@ "fabric-lifecycle-events-v1": "*", "fabric-key-binding-api-v1": "*", "fabric-networking-api-v1": "*", - "minecraft": "${minecraft_version}", + "minecraft": ${compatible_minecraft_versions}, "java": ">=${java_version}" }, - "suggests": { - "another-mod": "*" - }, "custom": { "modmenu": { diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index e3764750e..430d3ffec 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -9,7 +9,7 @@ issueTrackerURL="${issues}" modId="lod" #//mandatory version= "${version}" #//mandatory, gets the version number from jar populated by the build.gradle script displayName="${mod_name}" #//mandatory - authors="${authors}" + authors=${authors} #//updateJSONURL="https://change.me.example.invalid/updates.json" # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ displayURL="${homepage}" description= "${description}" #//mandatory. The description text for the mod diff --git a/gradle.properties b/gradle.properties index 297c34e5f..5bdfc3913 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ archives_base_name=DistantHorizons mod_version=1.6.2a mod_name=Distant Horizons mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow. -mod_authors=James Seibel, Leonardo Amato, Cola, coolGi2007, Ran, Leetom +mod_authors=["James Seibel", "Leonardo Amato", "Cola", "coolGi2007", "Ran", "Leetom"] mod_homepage=https://www.curseforge.com/minecraft/mc-mods/distant-horizons mod_source=https://gitlab.com/jeseibel/minecraft-lod-mod/ mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues @@ -18,4 +18,4 @@ toml_version=3.6.4 manifold_version=2022.1.7 ##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: -mcVer=1.17.1 \ No newline at end of file +mcVer=1.16.5 \ No newline at end of file