From 5476af5bb3e6fc17aba0a0a684924bc1022cfba3 Mon Sep 17 00:00:00 2001 From: tom lee Date: Wed, 2 Mar 2022 19:28:16 +0800 Subject: [PATCH 01/48] Fixed chunkloader to work with 1.18.2 --- .../mimicObject/ChunkLoader.java | 166 +++++++++--------- 1 file changed, 86 insertions(+), 80 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index adf03b444..8e6894e7d 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -9,13 +9,12 @@ import com.seibel.lod.core.api.ApiShared; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; import java.util.Arrays; -import java.util.HashMap; -import java.util.Locale; import java.util.Map; import java.util.Objects; import net.minecraft.core.Holder; import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.SectionPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -70,48 +69,52 @@ public class ChunkLoader private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData) { -// Registry biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + Registry biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); // Codec> biomeCodec = PalettedContainer.codec( // biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS)); -// -// int i = level.getSectionsCount(); -// LevelChunkSection[] chunkSections = new LevelChunkSection[i]; -// -// boolean isLightOn = chunkData.getBoolean("isLightOn"); -// boolean hasSkyLight = level.dimensionType().hasSkyLight(); -// ListTag tagSections = chunkData.getList("sections", 10); -// -// for (int j = 0; j < tagSections.size(); ++j) -// { -// CompoundTag tagSection = tagSections.getCompound(j); -// byte sectionYPos = tagSection.getByte("Y"); -// int sectionId = level.getSectionIndexFromSectionY(sectionYPos); -// if (sectionId >= 0 && sectionId < chunkSections.length) -// { -// PalettedContainer blockStateContainer; -// PalettedContainer> biomeContainer; -// -// blockStateContainer = tagSection.contains("block_states", 10) -// ? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error) -// : new PalettedContainer(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES); -// + Codec>> biomeCodec = PalettedContainer.codec( + biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS)); + + int i = level.getSectionsCount(); + LevelChunkSection[] chunkSections = new LevelChunkSection[i]; + + boolean isLightOn = chunkData.getBoolean("isLightOn"); + boolean hasSkyLight = level.dimensionType().hasSkyLight(); + ListTag tagSections = chunkData.getList("sections", 10); + + for (int j = 0; j < tagSections.size(); ++j) + { + CompoundTag tagSection = tagSections.getCompound(j); + byte sectionYPos = tagSection.getByte("Y"); + int sectionId = level.getSectionIndexFromSectionY(sectionYPos); + if (sectionId >= 0 && sectionId < chunkSections.length) + { + PalettedContainer blockStateContainer; + PalettedContainer> biomeContainer; + + blockStateContainer = tagSection.contains("block_states", 10) + ? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error) + : new PalettedContainer(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES); + + biomeContainer = tagSection.contains("biomes", 10) + ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string)).getOrThrow(false, LOGGER::error) + : new PalettedContainer>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); // biomeContainer = tagSection.contains("biomes", 10) // ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error) // : new PalettedContainer>(biomes, biomes.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); -// -// chunkSections[sectionId] = new LevelChunkSection(sectionYPos, blockStateContainer, biomeContainer); -// } -// -// if (!isLightOn) -// continue; -// -// if (tagSection.contains("BlockLight", 7)) -// lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("BlockLight")), true); -// if (hasSkyLight && tagSection.contains("SkyLight", 7)) -// lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("SkyLight")), true); -// } -// return chunkSections; - return null; + + chunkSections[sectionId] = new LevelChunkSection(sectionYPos, blockStateContainer, biomeContainer); + } + + if (!isLightOn) + continue; + + if (tagSection.contains("BlockLight", 7)) + lightEngine.queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("BlockLight")), true); + if (hasSkyLight && tagSection.contains("SkyLight", 7)) + lightEngine.queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, sectionYPos), new DataLayer(tagSection.getByteArray("SkyLight")), true); + } + return chunkSections; } private static void readHeightmaps(LevelChunk chunk, CompoundTag chunkData) @@ -128,53 +131,56 @@ public class ChunkLoader private static Map, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l) { -// Map, StructureStart> map = Maps.newHashMap(); -// CompoundTag compoundTag2 = compoundTag.getCompound("starts"); -// for (String string : compoundTag2.getAllKeys()) -// { + Map, StructureStart> map = Maps.newHashMap(); + Registry> structStartRegistry = structurePieceSerializationContext.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); + CompoundTag compoundTag2 = compoundTag.getCompound("starts"); + for (String string : compoundTag2.getAllKeys()) + { + ResourceLocation resourceLocation = ResourceLocation.tryParse(string); + ConfiguredStructureFeature structureFeature = structStartRegistry.get(resourceLocation); // String string2 = string.toLowerCase(Locale.ROOT); // ConfiguredStructureFeature structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2); -// if (structureFeature == null) -// { -// LOGGER.error("Unknown structure start: {}", (Object) string2); -// continue; -// } -// StructureStart structureStart = StructureFeature.loadStaticStart(structurePieceSerializationContext, compoundTag2.getCompound(string), l); -// if (structureStart == null) -// continue; -// map.put(structureFeature, structureStart); -// } -// return map; - return null; + if (structureFeature == null) + { + LOGGER.error("Unknown structure start: {}", resourceLocation); + continue; + } + StructureStart structureStart = StructureFeature.loadStaticStart(structurePieceSerializationContext, compoundTag2.getCompound(string), l); + if (structureStart == null) + continue; + map.put(structureFeature, structureStart); + } + return map; } - private static Map, LongSet> unpackStructureReferences(ChunkPos chunkPos, CompoundTag compoundTag) + private static Map, LongSet> unpackStructureReferences(RegistryAccess registryAccess, ChunkPos chunkPos, CompoundTag compoundTag) { -// Map, LongSet> map = Maps.newHashMap(); -// CompoundTag compoundTag2 = compoundTag.getCompound("References"); -// for (String string : compoundTag2.getAllKeys()) -// { + Map, LongSet> map = Maps.newHashMap(); + Registry> structRegistry = registryAccess.registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); + CompoundTag compoundTag2 = compoundTag.getCompound("References"); + for (String string : compoundTag2.getAllKeys()) + { + ResourceLocation resourceLocation = ResourceLocation.tryParse(string); + ConfiguredStructureFeature structureFeature = structRegistry.get(resourceLocation); // String string2 = string.toLowerCase(Locale.ROOT); -// // ConfiguredStructureFeature structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2); -// if (structureFeature == null) -// { -// LOGGER.warn("Found reference to unknown structure '{}' in chunk {}, discarding", (Object) string2, (Object) chunkPos); -// continue; -// } -// map.put(structureFeature, new LongOpenHashSet(Arrays.stream(compoundTag2.getLongArray(string)).filter(l -> -// { -// ChunkPos chunkPos2 = new ChunkPos(l); -// if (chunkPos2.getChessboardDistance(chunkPos) > 8) -// { -// LOGGER.warn("Found invalid structure reference [ {} @ {} ] for chunk {}.", (Object) string2, (Object) chunkPos2, (Object) chunkPos); -// return false; -// } -// return true; -// }).toArray())); -// } -// return map; - return null; + if (structureFeature == null) + { + LOGGER.warn("Found reference to unknown structure '{}' in chunk {}, discarding", resourceLocation, chunkPos); + continue; + } + map.put(structureFeature, new LongOpenHashSet(Arrays.stream(compoundTag2.getLongArray(string)).filter(l -> + { + ChunkPos chunkPos2 = new ChunkPos(l); + if (chunkPos2.getChessboardDistance(chunkPos) > 8) + { + LOGGER.warn("Found invalid structure reference [ {} @ {} ] for chunk {}.", resourceLocation, chunkPos2, chunkPos); + return false; + } + return true; + }).toArray())); + } + return map; } private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData) @@ -182,7 +188,7 @@ public class ChunkLoader CompoundTag tagStructures = chunkData.getCompound("structures"); chunk.setAllStarts( unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed())); - chunk.setAllReferences(unpackStructureReferences(chunk.getPos(), tagStructures)); + chunk.setAllReferences(unpackStructureReferences(level.registryAccess() ,chunk.getPos(), tagStructures)); } private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData) From ce10a43cc63f028fd26c08051efbc0daa78a03ce Mon Sep 17 00:00:00 2001 From: Ran <43445785+RanCraftPlayz@users.noreply.github.com> Date: Thu, 3 Mar 2022 14:34:47 +0600 Subject: [PATCH 02/48] Fix accesswidener for 1.18.2 --- common/src/main/resources/lod.accesswidener | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/resources/lod.accesswidener b/common/src/main/resources/lod.accesswidener index 13836d404..f568e46fe 100644 --- a/common/src/main/resources/lod.accesswidener +++ b/common/src/main/resources/lod.accesswidener @@ -1,6 +1,6 @@ accessWidener v1 named -# used when determining where to save files too +# used when determining where to save files to accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File; # used when rendering @@ -23,7 +23,7 @@ accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine L 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 Ljava/util/function/Supplier; +accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder; accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess; #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 From 7ddd48d132dbe21955418cc97fea9a15e785711d Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Mon, 7 Mar 2022 16:56:35 +1030 Subject: [PATCH 03/48] Updated what james did from 1.18.X to 1.18.2 --- .../lod/common/forge/LodForgeMethodCaller.java | 4 ++-- .../lod/common/wrappers/DependencySetup.java | 14 ++++++++------ .../lod/common/wrappers/chunk/ChunkWrapper.java | 15 ++++++++------- ...ftWrapper.java => MinecraftClientWrapper.java} | 11 +++++------ .../minecraft/MinecraftRenderWrapper.java | 8 ++++---- .../lod/common/wrappers/world/WorldWrapper.java | 6 ------ .../BatchGenerationEnvironment.java | 4 ++-- .../worldGeneration/GlobalParameters.java | 1 - core | 2 +- .../src/main/java/com/seibel/lod/fabric/Main.java | 11 +++++++---- ...dencySetup.java => FabricDependencySetup.java} | 13 ++++++++++--- .../main/java/com/seibel/lod/forge/ForgeMain.java | 7 +++++-- .../lod/forge/wrappers/ForgeDependencySetup.java | 9 +++++++++ 13 files changed, 61 insertions(+), 44 deletions(-) rename common/src/main/java/com/seibel/lod/common/wrappers/minecraft/{MinecraftWrapper.java => MinecraftClientWrapper.java} (97%) rename fabric/src/main/java/com/seibel/lod/fabric/wrappers/{DependencySetup.java => FabricDependencySetup.java} (64%) diff --git a/common/src/main/java/com/seibel/lod/common/forge/LodForgeMethodCaller.java b/common/src/main/java/com/seibel/lod/common/forge/LodForgeMethodCaller.java index d2e7d32f7..d88a3d7fe 100644 --- a/common/src/main/java/com/seibel/lod/common/forge/LodForgeMethodCaller.java +++ b/common/src/main/java/com/seibel/lod/common/forge/LodForgeMethodCaller.java @@ -1,6 +1,6 @@ package com.seibel.lod.common.forge; -import com.seibel.lod.common.wrappers.minecraft.MinecraftWrapper; +import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.core.Direction; import net.minecraft.world.level.block.Block; @@ -15,5 +15,5 @@ import java.util.Random; * @author Ran */ public interface LodForgeMethodCaller { - List getQuads(MinecraftWrapper mc, Block block, BlockState blockState, Direction direction, Random random); + List getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random); } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java index bb505cfd2..b8f60ab9c 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java @@ -1,15 +1,15 @@ package com.seibel.lod.common.wrappers; import com.seibel.lod.common.LodCommonMain; +import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper; -import com.seibel.lod.common.wrappers.minecraft.MinecraftWrapper; import com.seibel.lod.core.handlers.IReflectionHandler; import com.seibel.lod.core.handlers.ReflectionHandler; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.wrapperInterfaces.IVersionConstants; import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; +import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; /** * Binds all necessary dependencies, so we @@ -22,12 +22,14 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; * @version 12-1-2021 */ public class DependencySetup { - public static void createInitialBindings() { + public static void createInitialBindings() + { SingletonHandler.bind(IVersionConstants.class, VersionConstants.INSTANCE); - if (!LodCommonMain.serverSided) { - SingletonHandler.bind(IMinecraftWrapper.class, MinecraftWrapper.INSTANCE); + if (!LodCommonMain.serverSided) + { + SingletonHandler.bind(IMinecraftClientWrapper.class, MinecraftClientWrapper.INSTANCE); SingletonHandler.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE); - SingletonHandler.bind(IReflectionHandler.class, ReflectionHandler.createSingleton(MinecraftWrapper.INSTANCE.getOptions().getClass().getDeclaredFields(), MinecraftWrapper.INSTANCE.getOptions())); + SingletonHandler.bind(IReflectionHandler.class, ReflectionHandler.createSingleton(MinecraftClientWrapper.INSTANCE.getOptions().getClass().getDeclaredFields(), MinecraftClientWrapper.INSTANCE.getOptions())); } SingletonHandler.bind(IWrapperFactory.class, WrapperFactory.INSTANCE); 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 649f4e90e..053ab8350 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 @@ -28,13 +28,20 @@ import net.minecraft.world.level.levelgen.Heightmap; /** * * @author James Seibel - * @version 11-21-2021 + * @version 3-5-2022 */ public class ChunkWrapper implements IChunkWrapper { private final ChunkAccess chunk; private final LevelReader lightSource; + + public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource) + { + this.chunk = chunk; + this.lightSource = lightSource; + } + @Override public int getHeight(){ return chunk.getHeight(); @@ -69,12 +76,6 @@ public class ChunkWrapper implements IChunkWrapper BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); return BlockDetailMap.getBlockDetailWithCompleteTint(blockState, x, y, z, lightSource); } - - public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource) - { - this.chunk = chunk; - this.lightSource = lightSource; - } public ChunkAccess getChunk() { return chunk; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java similarity index 97% rename from common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftWrapper.java rename to common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java index c6c2a9748..1b2bde47a 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -27,10 +27,9 @@ import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.api.ApiShared; -import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.util.LodUtil; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; +import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IProfilerWrapper; import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper; @@ -68,11 +67,11 @@ import org.jetbrains.annotations.Nullable; * to allow for easier movement between Minecraft versions. * * @author James Seibel - * @version 9-16-2021 + * @version 3-5-2022 */ -public class MinecraftWrapper implements IMinecraftWrapper +public class MinecraftClientWrapper implements IMinecraftClientWrapper { - public static final MinecraftWrapper INSTANCE = new MinecraftWrapper(); + public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper(); public final Minecraft mc = Minecraft.getInstance(); @@ -85,7 +84,7 @@ public class MinecraftWrapper implements IMinecraftWrapper private ProfilerWrapper profilerWrapper; - private MinecraftWrapper() + private MinecraftClientWrapper() { } 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 3f71e81dc..e54ad7d93 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 @@ -24,7 +24,7 @@ import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; +import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; import com.seibel.lod.common.wrappers.McObjectConverter; @@ -58,7 +58,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper private static final Minecraft MC = Minecraft.getInstance(); private static final GameRenderer GAME_RENDERER = MC.gameRenderer; - private static final WrapperFactory FACTORY = WrapperFactory.INSTANCE; + private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE; @Override public Vec3f getLookAtVector() @@ -178,10 +178,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper }).collect(Collectors.toCollection(HashSet::new))); } catch (LinkageError e) { try { - MinecraftWrapper.INSTANCE.sendChatMessage( + MinecraftClientWrapper.INSTANCE.sendChatMessage( "\u00A7e\u00A7l\u00A7uWARNING: Distant Horizons: getVanillaRenderedChunks method failed." + " Using Backup Method."); - MinecraftWrapper.INSTANCE.sendChatMessage( + MinecraftClientWrapper.INSTANCE.sendChatMessage( "\u00A7eOverdraw prevention will be worse than normal."); } catch (Exception e2) {} ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java index 822012e9c..c944503af 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java @@ -128,12 +128,6 @@ public class WorldWrapper implements IWorldWrapper return world.dimensionType().hasSkyLight(); } - @Override - public boolean isEmpty() - { - return world == null; - } - @Override public int getHeight() { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 2c797b3c5..e120eb8ac 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -30,7 +30,7 @@ import com.seibel.lod.core.objects.lod.LodDimension; import com.seibel.lod.core.util.GridList; import com.seibel.lod.core.util.LodThreadFactory; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; +import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper; import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper; @@ -227,7 +227,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv public boolean unsafeThreadingRecorded = false; //public boolean safeMode = false; private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); - private static final IMinecraftWrapper MC = SingletonHandler.get(IMinecraftWrapper.class); + private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class); public static final long EXCEPTION_TIMER_RESET_TIME = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); public static final int EXCEPTION_COUNTER_TRIGGER = 20; public int unknownExceptionCount = 0; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java index 069c0606f..47085aca1 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java @@ -5,7 +5,6 @@ import com.mojang.datafixers.DataFixer; import com.seibel.lod.core.builders.lodBuilding.LodBuilder; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.objects.lod.LodDimension; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; diff --git a/core b/core index d84d53589..3f091af3f 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d84d535896a911340cc661e349a7f813ce0b0c9b +Subproject commit 3f091af3f8393397670c21d1a93871a8bb1dbf68 diff --git a/fabric/src/main/java/com/seibel/lod/fabric/Main.java b/fabric/src/main/java/com/seibel/lod/fabric/Main.java index 346132e7a..b4b61d90f 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/Main.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/Main.java @@ -34,7 +34,7 @@ import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker; import com.seibel.lod.fabric.wrappers.modAccessor.OptifineAccessor; import com.seibel.lod.fabric.wrappers.modAccessor.SodiumAccessor; import com.seibel.lod.fabric.wrappers.modAccessor.StarlightAccessor; -import com.seibel.lod.fabric.wrappers.DependencySetup; +import com.seibel.lod.fabric.wrappers.FabricDependencySetup; import net.fabricmc.api.ClientModInitializer; @@ -66,8 +66,8 @@ public class Main implements ClientModInitializer public static void init() { LodCommonMain.initConfig(); LodCommonMain.startup(null, false, new NetworkHandler()); - DependencySetup.createInitialBindings(); - SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); + FabricDependencySetup.createInitialBindings(); + FabricDependencySetup.finishBinding(); ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); // Check if this works @@ -82,12 +82,15 @@ public class Main implements ClientModInitializer if (SingletonHandler.get(IModChecker.class).isModLoaded("optifine")) { ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor()); } + + ModAccessorHandler.finishBinding(); } public static void initServer() { LodCommonMain.initConfig(); LodCommonMain.startup(null, true, new NetworkHandler()); - DependencySetup.createInitialBindings(); + FabricDependencySetup.createInitialBindings(); + FabricDependencySetup.finishBinding(); ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); } } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/DependencySetup.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java similarity index 64% rename from fabric/src/main/java/com/seibel/lod/fabric/wrappers/DependencySetup.java rename to fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java index d9486d44f..f412b35d0 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/DependencySetup.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java @@ -1,9 +1,10 @@ package com.seibel.lod.fabric.wrappers; -import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton; +import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; +import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker; /** * Binds all necessary dependencies, so we @@ -13,12 +14,18 @@ import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton; * * @author James Seibel * @author Ran - * @version 12-1-2021 + * @version 3-5-2022 */ -public class DependencySetup +public class FabricDependencySetup { public static void createInitialBindings() { + SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); + SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE); } + + public static void finishBinding() { + SingletonHandler.finishBinding(); + } } diff --git a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java index 652a89e20..559c49cb3 100644 --- a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java +++ b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java @@ -22,6 +22,7 @@ package com.seibel.lod.forge; import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.common.forge.LodForgeMethodCaller; import com.seibel.lod.common.wrappers.config.ConfigGui; +import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.lod.common.wrappers.minecraft.MinecraftWrapper; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.api.ApiShared; @@ -72,8 +73,8 @@ public class ForgeMain implements LodForgeMethodCaller LodCommonMain.initConfig(); LodCommonMain.startup(this, !FMLLoader.getDist().isClient(), new NetworkHandler()); ForgeDependencySetup.createInitialBindings(); + ForgeDependencySetup.finishBinding(); ApiShared.LOGGER.info("Distant Horizons initializing..."); - SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); } public ForgeMain() @@ -89,6 +90,8 @@ public class ForgeMain implements LodForgeMethodCaller ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor()); } + ModAccessorHandler.finishBinding(); + ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class, () -> new ConfigGuiHandler.ConfigGuiFactory((client, parent) -> ConfigGui.getScreen(parent, ""))); forgeClientProxy = new ForgeClientProxy(); @@ -97,7 +100,7 @@ public class ForgeMain implements LodForgeMethodCaller private final ModelDataMap dataMap = new ModelDataMap.Builder().build(); @Override - public List getQuads(MinecraftWrapper mc, Block block, BlockState blockState, Direction direction, Random random) { + public List getQuads(MinecraftClientWrapper mc, Block block, BlockState blockState, Direction direction, Random random) { return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, dataMap); } } diff --git a/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java index 53c8b6794..bd1a13df8 100644 --- a/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java +++ b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java @@ -4,6 +4,8 @@ import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; +import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; +import com.seibel.lod.forge.wrappers.modAccessor.ModChecker; /** * Binds all necessary dependencies so we @@ -19,6 +21,13 @@ public class ForgeDependencySetup { public static void createInitialBindings() { + SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); + SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE); } + + public static void finishBinding() + { + SingletonHandler.finishBinding(); + } } From a663bf9f191f43b54704a5108ff5c796fc0f91ed Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Tue, 8 Mar 2022 17:43:10 +1030 Subject: [PATCH 04/48] Added the multiplayer folder thing from 1.18.X to 1.18.2 and fixed building --- .../java/com/seibel/lod/common/Config.java | 13 +++++++++ .../config/LodConfigWrapperSingleton.java | 29 +++++++++++++++++++ core | 2 +- .../java/com/seibel/lod/forge/ForgeMain.java | 1 - 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index 2226c1075..f3a3804d8 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -25,6 +25,7 @@ import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.*; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator; /** @@ -71,6 +72,9 @@ public class Config @ConfigAnnotations.ScreenEntry public static WorldGenerator worldGenerator; + @ConfigAnnotations.ScreenEntry + public static Multiplayer multiplayer; + @ConfigAnnotations.ScreenEntry public static Advanced advanced; @@ -208,6 +212,15 @@ public class Config public static BlocksToAvoid blocksToAvoid = IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT; } + + public static class Multiplayer { + @ConfigAnnotations.FileComment + public static String _serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DESC; + @ConfigAnnotations.Entry + public static ServerFolderNameMode serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DEFAULT; + } + + public static class Advanced { @ConfigAnnotations.ScreenEntry diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index f9993c7d6..789c7e686 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -3,6 +3,7 @@ package com.seibel.lod.common.wrappers.config; import com.seibel.lod.core.enums.config.*; import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.common.Config; /** @@ -28,6 +29,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton { public final IGraphics graphics; public final IWorldGenerator worldGenerator; + public final IMultiplayer multiplayer; public final IAdvanced advanced; @@ -43,6 +45,11 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton return worldGenerator; } + @Override + public IMultiplayer multiplayer() { + return multiplayer; + } + @Override public IAdvanced advanced() { @@ -70,6 +77,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton { graphics = new Graphics(); worldGenerator = new WorldGenerator(); + multiplayer = new Multiplayer(); advanced = new Advanced(); } @@ -384,6 +392,27 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton + //=====================// + // Multiplayer Configs // + //=====================// + public static class Multiplayer implements IMultiplayer + { + @Override + public ServerFolderNameMode getServerFolderNameMode() + { + return Config.Client.Multiplayer.serverFolderNameMode; + } + @Override + public void setServerFolderNameMode(ServerFolderNameMode newServerFolderNameMode) + { + ConfigGui.editSingleOption.getEntry("client.multiplayer.serverFolderNameMode").value = newServerFolderNameMode; + ConfigGui.editSingleOption.saveOption("client.multiplayer.serverFolderNameMode"); + } + + + } + + //============================// // AdvancedModOptions Configs // diff --git a/core b/core index 3f091af3f..510058b7d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 3f091af3f8393397670c21d1a93871a8bb1dbf68 +Subproject commit 510058b7dfa8eb29e0d1de7028e54bea2691e53e diff --git a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java index 559c49cb3..79d74901a 100644 --- a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java +++ b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java @@ -23,7 +23,6 @@ import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.common.forge.LodForgeMethodCaller; import com.seibel.lod.common.wrappers.config.ConfigGui; import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; -import com.seibel.lod.common.wrappers.minecraft.MinecraftWrapper; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.handlers.ReflectionHandler; From c5cdc2760f813403351e204f3fc7e82b35160e29 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Tue, 8 Mar 2022 16:05:30 +0800 Subject: [PATCH 05/48] Update core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 510058b7d..d731424e9 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 510058b7dfa8eb29e0d1de7028e54bea2691e53e +Subproject commit d731424e93ae83170c3e9a61688887a7cadf5f8a From 151d5480998ac03bb565c0889380a6e0c29e2c3c Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Tue, 8 Mar 2022 23:27:14 +0800 Subject: [PATCH 06/48] Update core + Fix biome blending --- .../common/wrappers/McObjectConverter.java | 17 +- .../common/wrappers/block/BlockDetailMap.java | 271 +---------------- .../wrappers/block/BlockDetailWrapper.java | 284 ++++++++++++++++++ .../common/wrappers/chunk/ChunkWrapper.java | 16 +- .../BatchGenerationEnvironment.java | 2 +- .../mimicObject/LightedWorldGenRegion.java | 50 ++- core | 2 +- 7 files changed, 366 insertions(+), 276 deletions(-) create mode 100644 common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java b/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java index 154e402bc..b54836f4c 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java @@ -22,9 +22,12 @@ package com.seibel.lod.common.wrappers; import java.nio.FloatBuffer; import com.mojang.math.Matrix4f; +import com.seibel.lod.common.wrappers.block.BlockPosWrapper; import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.objects.math.Mat4f; +import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; +import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; /** @@ -48,17 +51,29 @@ public class McObjectConverter static final Direction[] directions; + static final LodDirection[] lodDirections; static { LodDirection[] lodDirs = LodDirection.values(); directions = new Direction[lodDirs.length]; + lodDirections = new LodDirection[lodDirs.length]; for (LodDirection lodDir : lodDirs) { - directions[lodDir.ordinal()] = Direction.byName(lodDir.name()); + Direction dir = Direction.byName(lodDir.name()); + directions[lodDir.ordinal()] = dir; + lodDirections[dir.ordinal()] = lodDir; } } + public static BlockPos Convert(AbstractBlockPosWrapper wrappedPos) { + return new BlockPos(wrappedPos.getX(),wrappedPos.getY(), wrappedPos.getZ()); + } + public static Direction Convert(LodDirection lodDirection) { return directions[lodDirection.ordinal()]; } + public static LodDirection Convert(Direction direction) + { + return lodDirections[direction.ordinal()]; + } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailMap.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailMap.java index 280a251f8..4bf19e19c 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailMap.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailMap.java @@ -1,286 +1,27 @@ package com.seibel.lod.common.wrappers.block; -import java.util.List; -import java.util.Random; import java.util.concurrent.ConcurrentHashMap; -import com.seibel.lod.core.api.ApiShared; -import com.seibel.lod.core.util.ColorUtil; -import com.seibel.lod.core.wrapperInterfaces.block.BlockDetail; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.color.block.BlockColors; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.FlowerBlock; -import net.minecraft.world.level.block.LeavesBlock; -import net.minecraft.world.level.block.LiquidBlock; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.shapes.VoxelShape; public class BlockDetailMap { - public static final int FLOWER_COLOR_SCALE = 5; - public static final Random random = new Random(0); - - //TODO: Perhaps make this not just use the first frame? - //FIXME: Stuff is wrong. - private static int calculateColorFromTexture(TextureAtlasSprite texture, boolean useFlowerScaling, boolean useFastLeaf) { - - int count = 0; - double alpha = 0; - double red = 0; - double green = 0; - double blue = 0; - int tempColor; - - { - // textures normally use u and v instead of x and y - for (int u = 0; u < texture.getWidth(); u++) - { - for (int v = 0; v < texture.getHeight(); v++) - { - //note: Minecraft color format is: 0xAA BB GG RR - //________ DH mod color format is: 0xAA RR GG BB - //OpenGL RGBA format native order: 0xRR GG BB AA - //_ OpenGL RGBA format Java Order: 0xAA BB GG RR - tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v); - - double r = ((tempColor & 0x000000FF) )/255.; - double g = ((tempColor & 0x0000FF00) >>> 8)/255.; - double b = ((tempColor & 0x00FF0000) >>> 16)/255.; - double a = ((tempColor & 0xFF000000) >>> 24)/255.; - int scale = 1; - - if (useFastLeaf) { - r *= a; - g *= a; - b *= a; - a = 1.; - } else if (a==0.) { - continue; - } else if (useFlowerScaling && (g+0.1 biomeDetailMap = null; - BlockDetail blockDetail; - BlockDetail defaultTintedDetail = null; - boolean requireResolving; - @SuppressWarnings("unused") - boolean requireShade; //TODO: Add back using this in renderer - @SuppressWarnings("unused") - boolean scaleFlowerColor; //FIXME: Do I need to scale the tint color??? - int tintIndex; - - static boolean isBlockToBeAvoid(Block b) { - for (Block bta : BLOCK_TO_AVOID) - if (bta==b) return true; - return false; - } - - static boolean hasNoCollision(BlockState bs, BlockPos pos, LevelReader getter) { - if (!bs.getFluidState().isEmpty() || bs.getBlock() instanceof LiquidBlock) // Is blockState a fluid? - return false; - if (bs.getCollisionShape(getter, pos).isEmpty()) - return true; - return false; - } - static boolean hasOnlyNonFullFace(BlockState bs, BlockPos pos, LevelReader getter) { - if (!bs.getFluidState().isEmpty() || bs.getBlock() instanceof LiquidBlock) // Is blockState a fluid? - return false; - VoxelShape voxelShape = bs.getShape(getter, pos); - if (voxelShape.isEmpty()) return true; - AABB bbox = voxelShape.bounds(); - double xWidth = (bbox.maxX - bbox.minX); - double yWidth = (bbox.maxY - bbox.minY); - double zWidth = (bbox.maxZ - bbox.minZ); - return xWidth < 1 && zWidth < 1 && yWidth < 1; - } - - static BlockDetailCache make(BlockState bs, BlockPos pos, LevelReader getter) { - boolean noCol, nonFull, canOcclude; - if(!bs.getFluidState().isEmpty()) { - bs = bs.getFluidState().createLegacyBlock(); - FluidState fs = bs.getFluidState(); - fs.getType(); - noCol = false; - nonFull = false; - canOcclude = false; - BlockDetailCache result = new BlockDetailCache(fs); - //ApiShared.LOGGER.info(fs.toString()+" = ["+result+"]"); - return result; - } else { - if (bs.getRenderShape() != RenderShape.MODEL) return NULL_BLOCK_DETAIL; - if (isBlockToBeAvoid(bs.getBlock())) return NULL_BLOCK_DETAIL; - //BlocksToAvoid toAvoid = CONFIG.client().worldGenerator().getBlocksToAvoid(); - noCol = hasNoCollision(bs, pos, getter); - nonFull = hasOnlyNonFullFace(bs, pos, getter); - canOcclude = bs.canOcclude(); - List quads = null; - for (Direction direction : DIRECTION_ORDER) - { - quads = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(bs).getQuads(bs, direction, random); - if (!quads.isEmpty() && !(bs.getBlock() instanceof RotatedPillarBlock && direction == Direction.UP)) - break; - }; - if (quads == null || quads.isEmpty()) return NULL_BLOCK_DETAIL; - BlockDetailCache result = new BlockDetailCache(canOcclude, noCol, nonFull, quads.get(0), - bs.getBlock() instanceof FlowerBlock, bs.getBlock() instanceof LeavesBlock); - // ApiShared.LOGGER.info(bs.toString()+" = ["+result+"]"); - return result; - } - } - - BlockDetailCache(boolean isFullBlock, boolean noCol, boolean nonFull, BakedQuad quad, boolean useFlowerScaling, boolean useFastLeaf) { - requireResolving = quad.isTinted(); - requireShade = quad.isShade(); - tintIndex = quad.getTintIndex(); - scaleFlowerColor = useFlowerScaling; - blockDetail = new BlockDetail(calculateColorFromTexture(quad.getSprite(), useFlowerScaling, useFastLeaf), isFullBlock, noCol, nonFull); - if (quad.isTinted()) biomeDetailMap = new ConcurrentHashMap(); - } - - BlockDetailCache(FluidState fluid) { - requireResolving = true; // TODO: Maybe in the future recheck that there really is no way to see if a fluid needs tinting - requireShade = false; - tintIndex = 0; // Vanilla doesn't use this index currently. (Checked at 1.18.X, See BlockColors.class) - scaleFlowerColor = false; - TextureAtlasSprite text = Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(fluid.createLegacyBlock()).getParticleIcon(); - blockDetail = new BlockDetail(calculateColorFromTexture(text, false, false), true, false, false); - biomeDetailMap = new ConcurrentHashMap(); - } - - private BlockDetailCache() - { - //DUMMY CREATOR - } - - BlockDetail getResolvedBlockDetail(BlockState bs, int x, int y, int z, LevelReader getter) { - if (!requireResolving) return blockDetail; - BlockPos pos = new BlockPos(x,y,z); - Biome biome = getter.getBiome(pos).value(); - BlockDetail tintDetail = biomeDetailMap.get(biome); - if (tintDetail == null) { - if (!bs.getFluidState().isEmpty()) bs = bs.getFluidState().createLegacyBlock(); - BlockColors bc = Minecraft.getInstance().getBlockColors(); - int tintColor = bc.getColor(bs, getter, pos, tintIndex); - tintColor = ColorUtil.multiplyARGBwithRGB(blockDetail.color, tintColor); - tintDetail = new BlockDetail(tintColor, blockDetail.isFullBlock, - blockDetail.hasNoCollision, blockDetail.hasOnlyNonFullFace); - BlockDetail tintDetailCAS = biomeDetailMap.putIfAbsent(biome, tintDetail); - if (tintDetailCAS != null) tintDetail = tintDetailCAS; - } - return tintDetail; - } - - // Note: this one won't resolve biome based or pos based colors. (Kinda like GUI block icons) - BlockDetail getResolvedBlockDetail(BlockState bs) { - if (!requireResolving) return blockDetail; - if (defaultTintedDetail != null) return defaultTintedDetail; - - BlockColors bc = Minecraft.getInstance().getBlockColors(); - if (!bs.getFluidState().isEmpty()) bs = bs.getFluidState().createLegacyBlock(); - int tintColor = bc.getColor(bs, null, null, tintIndex); - if (tintColor == -1) { - defaultTintedDetail = blockDetail; - } - else { - defaultTintedDetail = new BlockDetail(ColorUtil.multiplyARGBwithRGB(blockDetail.color, tintColor), - blockDetail.isFullBlock, blockDetail.hasNoCollision, blockDetail.hasOnlyNonFullFace); - } - return defaultTintedDetail; - } - - @Override - public String toString() { - return "[BlockDetail: "+blockDetail+", RequireResolving: "+requireResolving+", requireShade: "+requireShade+", scaleFlowerColor: "+scaleFlowerColor+"]"; - } - - } - - - - private static ConcurrentHashMap map = new ConcurrentHashMap(); + private static ConcurrentHashMap map = new ConcurrentHashMap(); private BlockDetailMap() {} - private static BlockDetailCache getOrMakeBlockDetailCache(BlockState bs, BlockPos pos, LevelReader getter) { - BlockDetailCache cache = map.get(bs); + public static BlockDetailWrapper getOrMakeBlockDetailCache(BlockState bs, BlockPos pos, LevelReader getter) { + BlockDetailWrapper cache = map.get(bs); if (cache != null) return cache; if (bs.getFluidState().isEmpty()) { - cache = BlockDetailCache.make(bs, pos, getter); + cache = BlockDetailWrapper.make(bs, pos, getter); } else { - cache = BlockDetailCache.make(bs.getFluidState().createLegacyBlock(), pos, getter); + cache = BlockDetailWrapper.make(bs.getFluidState().createLegacyBlock(), pos, getter); } - BlockDetailCache cacheCAS = map.putIfAbsent(bs, cache); + BlockDetailWrapper cacheCAS = map.putIfAbsent(bs, cache); return cacheCAS==null ? cache : cacheCAS; } - - - // Return null means skip the block - public static BlockDetail getBlockDetail(BlockState bs) { - BlockDetailCache cache = getOrMakeBlockDetailCache(bs, new BlockPos(0, 0, 0), null); - if (cache == BlockDetailCache.NULL_BLOCK_DETAIL) return null; - return cache.getResolvedBlockDetail(bs); - } - - // Return null means skip the block - public static BlockDetail getBlockDetailWithCompleteTint(BlockState bs, int x, int y, int z, LevelReader tintGetter) { - BlockDetailCache cache = getOrMakeBlockDetailCache(bs, new BlockPos(x,y,z), tintGetter); - if (cache == BlockDetailCache.NULL_BLOCK_DETAIL) return null; - return cache.getResolvedBlockDetail(bs, x, y, z, tintGetter); - } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java new file mode 100644 index 000000000..8b4ff8bf2 --- /dev/null +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java @@ -0,0 +1,284 @@ +package com.seibel.lod.common.wrappers.block; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import com.seibel.lod.common.wrappers.McObjectConverter; +import com.seibel.lod.common.wrappers.chunk.ChunkWrapper; +import com.seibel.lod.core.enums.LodDirection; +import com.seibel.lod.core.util.ColorUtil; +import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; +import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper; +import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FlowerBlock; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class BlockDetailWrapper extends IBlockDetailWrapper +{ + public static final int FLOWER_COLOR_SCALE = 5; + + public static final Random random = new Random(0); + + enum ColorMode { + Default, + Flower, + Leaves; + static ColorMode getColorMode(Block b) { + if (b instanceof LeavesBlock) return Leaves; + if (b instanceof FlowerBlock) return Flower; + return Default; + } + } + //TODO: Perhaps make this not just use the first frame? + private static int calculateColorFromTexture(TextureAtlasSprite texture, ColorMode colorMode) { + + int count = 0; + double alpha = 0; + double red = 0; + double green = 0; + double blue = 0; + int tempColor; + + { + // textures normally use u and v instead of x and y + for (int u = 0; u < texture.getWidth(); u++) + { + for (int v = 0; v < texture.getHeight(); v++) + { + //note: Minecraft color format is: 0xAA BB GG RR + //________ DH mod color format is: 0xAA RR GG BB + //OpenGL RGBA format native order: 0xRR GG BB AA + //_ OpenGL RGBA format Java Order: 0xAA BB GG RR + tempColor = TextureAtlasSpriteWrapper.getPixelRGBA(texture, 0, u, v); + + double r = ((tempColor & 0x000000FF) )/255.; + double g = ((tempColor & 0x0000FF00) >>> 8)/255.; + double b = ((tempColor & 0x00FF0000) >>> 16)/255.; + double a = ((tempColor & 0xFF000000) >>> 24)/255.; + int scale = 1; + + if (colorMode == ColorMode.Leaves) { + r *= a; + g *= a; + b *= a; + a = 1.; + } else if (a==0.) { + continue; + } else if (colorMode == ColorMode.Flower && (g+0.1 quads = null; + for (Direction direction : DIRECTION_ORDER) + { + quads = Minecraft.getInstance().getModelManager().getBlockModelShaper(). + getBlockModel(state).getQuads(state, direction, random); + if (!quads.isEmpty() && + !(state.getBlock() instanceof RotatedPillarBlock && direction == Direction.UP)) + break; + }; + if (quads != null && !quads.isEmpty()) { + needPostTinting = quads.get(0).isTinted(); + needShade = quads.get(0).isShade(); + tintIndex = quads.get(0).getTintIndex(); + baseColor = calculateColorFromTexture(quads.get(0).getSprite(), + ColorMode.getColorMode(state.getBlock())); + } + } else { // Liquid Block + + needPostTinting = true; + needShade = false; + tintIndex = 0; + baseColor = calculateColorFromTexture(Minecraft.getInstance().getModelManager().getBlockModelShaper().getParticleIcon(state), + ColorMode.getColorMode(state.getBlock())); + + } + isColorResolved = true; + } + + + + @Override + public int getAndResolveFaceColor(LodDirection dir, IChunkWrapper chunk, AbstractBlockPosWrapper blockPos) + { + // FIXME: impl per-face colors + resolveColors(); + if (!needPostTinting) return baseColor; + int tintColor = Minecraft.getInstance().getBlockColors() + .getColor(state, ((ChunkWrapper)chunk).getColorResolver(), + McObjectConverter.Convert(blockPos), tintIndex); + if (tintColor == -1) return baseColor; + return ColorUtil.multiplyARGBwithRGB(baseColor, tintColor); + } + + @Override + public boolean hasFaceCullingFor(LodDirection dir) + { + resolveShapes(); + return !dontOccludeFaces[dir.ordinal()]; + } + + @Override + public boolean hasNoCollision() + { + resolveShapes(); + return noCollision; + } + + @Override + public boolean noFaceIsFullFace() + { + resolveShapes(); + return noFullFace; + } + + @Override + public String serialize() + { + // FIXME: Impl this for the blockState Storage stuff + return null; + } + + @Override + protected boolean isSame(IBlockDetailWrapper iBlockDetail) + { + return ((BlockDetailWrapper)iBlockDetail).state.getBlock().equals(state.getBlock()); + } + +} 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 053ab8350..2cd61bd18 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 @@ -2,18 +2,17 @@ package com.seibel.lod.common.wrappers.chunk; import com.seibel.lod.core.util.LevelPosUtil; import com.seibel.lod.core.util.LodUtil; -import com.seibel.lod.core.wrapperInterfaces.block.BlockDetail; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.lod.common.wrappers.WrapperUtil; import com.seibel.lod.common.wrappers.block.BlockDetailMap; +import com.seibel.lod.common.wrappers.block.BlockDetailWrapper; import com.seibel.lod.common.wrappers.world.BiomeWrapper; import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion; import net.minecraft.core.BlockPos; import net.minecraft.core.QuartPos; -import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.block.LiquidBlockContainer; @@ -72,9 +71,11 @@ public class ChunkWrapper implements IChunkWrapper } @Override - public BlockDetail getBlockDetail(int x, int y, int z) { - BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); - return BlockDetailMap.getBlockDetailWithCompleteTint(blockState, x, y, z, lightSource); + public BlockDetailWrapper getBlockDetail(int x, int y, int z) { + BlockPos pos = new BlockPos(x,y,z); + BlockState blockState = chunk.getBlockState(pos); + BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; } public ChunkAccess getChunk() { @@ -176,4 +177,9 @@ public class ChunkWrapper implements IChunkWrapper return true; } + public LevelReader getColorResolver() + { + return lightSource; + } + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index e120eb8ac..142c859cf 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -429,7 +429,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } e.pEvent.emptyNano = System.nanoTime(); e.refreshTimeout(); - region = new LightedWorldGenRegion(params.level, lightEngine, e.tParam.structFeat, chunks, ChunkStatus.STRUCTURE_STARTS, rangeEmpty, e.lightMode, generator); + region = new LightedWorldGenRegion(params.level, lightEngine, chunks, ChunkStatus.STRUCTURE_STARTS, rangeEmpty, e.lightMode, generator); adaptor.setRegion(region); e.tParam.makeStructFeat(region); referencedChunks = chunks.subGrid(e.range); 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 5134626c5..ea87fecfb 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 @@ -10,16 +10,24 @@ import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.enums.config.LightGenerationMode; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.minecraft.Util; +import net.minecraft.client.Minecraft; +import net.minecraft.client.color.block.BlockTintCache; +import net.minecraft.client.renderer.BiomeColors; import net.minecraft.core.BlockPos; +import net.minecraft.core.Cursor3D; import net.minecraft.core.SectionPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.WorldGenRegion; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.ColorResolver; import net.minecraft.world.level.LevelHeightAccessor; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.StructureFeatureManager; +import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -40,21 +48,25 @@ public class LightedWorldGenRegion extends WorldGenRegion { public final int size; private final ChunkPos firstPos; private final List cache; - private final StructureFeatureManager structFeat; Long2ObjectOpenHashMap chunkMap = new Long2ObjectOpenHashMap(); public LightedWorldGenRegion(ServerLevel serverLevel, WorldGenLevelLightEngine lightEngine, - StructureFeatureManager structFeat, List list, ChunkStatus chunkStatus, int i, + List list, ChunkStatus chunkStatus, int i, LightGenerationMode lightMode, EmptyChunkGenerator generator) { super(serverLevel, list, chunkStatus, i); this.lightMode = lightMode; this.firstPos = list.get(0).getPos(); this.generator = generator; - this.structFeat = structFeat; light = lightEngine; writeRadius = i; cache = list; size = Mth.floor(Math.sqrt(list.size())); + + this.tintCaches = Util.make(new Object2ObjectArrayMap(3), object2ObjectArrayMap -> { + object2ObjectArrayMap.put(BiomeColors.GRASS_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.GRASS_COLOR_RESOLVER);})); + object2ObjectArrayMap.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER);})); + object2ObjectArrayMap.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER);})); + }); } // Bypass BCLib mixin overrides. @@ -226,4 +238,36 @@ public class LightedWorldGenRegion extends WorldGenRegion { return (getBrightness(LightLayer.SKY, blockPos) >= getMaxLightLevel()); } + + + private final Object2ObjectArrayMap tintCaches; + + public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) + { + BlockTintCache blockTintCache = (BlockTintCache) this.tintCaches.get(colorResolver); + return blockTintCache.getColor(blockPos); + } + + public int calculateBlockTint(BlockPos blockPos, ColorResolver colorResolver) + { + int i = (Minecraft.getInstance()).options.biomeBlendRadius; + if (i == 0) + return colorResolver.getColor((Biome) getBiome(blockPos).value(), blockPos.getX(), blockPos.getZ()); + int j = (i * 2 + 1) * (i * 2 + 1); + int k = 0; + int l = 0; + int m = 0; + Cursor3D cursor3D = new Cursor3D(blockPos.getX() - i, blockPos.getY(), blockPos.getZ() - i, blockPos.getX() + i, blockPos.getY(), blockPos.getZ() + i); + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + while (cursor3D.advance()) + { + mutableBlockPos.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ()); + int n = colorResolver.getColor((Biome) getBiome((BlockPos) mutableBlockPos).value(), mutableBlockPos.getX(), mutableBlockPos.getZ()); + k += (n & 0xFF0000) >> 16; + l += (n & 0xFF00) >> 8; + m += n & 0xFF; + } + return (k / j & 0xFF) << 16 | (l / j & 0xFF) << 8 | m / j & 0xFF; + } + } \ No newline at end of file diff --git a/core b/core index d731424e9..c9cabd8a3 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d731424e93ae83170c3e9a61688887a7cadf5f8a +Subproject commit c9cabd8a321a63cbd971bfae41b54d224feb43c2 From eb3d8d9da517a08479fd44c08f2c457885c7ba39 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Wed, 9 Mar 2022 16:14:16 +0800 Subject: [PATCH 07/48] Add Manifold Preprocessor plugin to gradle --- build.gradle | 8 ++++++++ common/src/main/java/com/seibel/lod/common/Config.java | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fec9a4e1b..d86d62674 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ buildscript { plugins { id "architectury-plugin" version "3.4-SNAPSHOT" id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false + id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha" } apply plugin: JarMergerPlugin @@ -34,6 +35,9 @@ subprojects { p -> minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" // The following line declares the mojmap mappings mappings loom.officialMojangMappings() + + //Manifold + annotationProcessor 'systems.manifold:manifold-preprocessor:2022.1.5' // Toml implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") @@ -142,6 +146,10 @@ allprojects { p -> tasks.withType(JavaCompile) { + + // Add Manifold Preprocessor + options.compilerArgs += ['-Xplugin:Manifold'] + if (p != project(":core")) { // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. options.release = 17 diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index f3a3804d8..2260b6898 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -28,11 +28,17 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.I import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator; + + +#define CONFIG + /** * This handles any configuration the user has access to. * @author coolGi2007 * @version 12-12-2021 */ + +#if CONFIG public class Config //public class Config extends TinyConfig { @@ -52,7 +58,7 @@ public class Config // |-> Debugging // Since the original config system uses forge stuff, that means we have to rewrite the whole config system - + @ConfigAnnotations.ScreenEntry public static Client client; @@ -286,3 +292,4 @@ public class Config } } } +#endif \ No newline at end of file From c4e2d3fb0f8d7504df3c05857559a0a6a3e114a5 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Wed, 9 Mar 2022 16:21:44 +0800 Subject: [PATCH 08/48] Remove unused stuff --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d86d62674..94df09540 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,6 @@ buildscript { plugins { id "architectury-plugin" version "3.4-SNAPSHOT" id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false - id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha" } apply plugin: JarMergerPlugin @@ -77,6 +76,9 @@ allprojects { p -> mavenCentral() // used to download and compile dependencies from git repos maven { url 'https://jitpack.io' } + + // For Manifold Preprocessor + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } // Required for importing Modrinth mods maven { From 835beb607ddb8ae673f91cb693c3dc1d394490bb Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 9 Mar 2022 23:06:34 -0600 Subject: [PATCH 09/48] Close #207 (re-add brightness/contrast configs) --- .../java/com/seibel/lod/common/Config.java | 12 +++++++++- .../config/LodConfigWrapperSingleton.java | 24 +++++++++++++++++++ core | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index f3a3804d8..03b862f27 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -160,11 +160,21 @@ public class Config public static String _vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DESC; @ConfigAnnotations.Entry public static VanillaOverdraw vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DEFAULT; - + @ConfigAnnotations.FileComment public static String _useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DESC; @ConfigAnnotations.Entry public static boolean useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DESC; + @ConfigAnnotations.Entry + public static double brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DESC; + @ConfigAnnotations.Entry + public static double saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DEFAULT; /* @ConfigAnnotations.FileComment diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 789c7e686..e14915705 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -305,6 +305,30 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.useExtendedNearClipPlane").value = newUseExtendedNearClipPlane; ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.useExtendedNearClipPlane"); } + + @Override + public double getBrightnessMultiplier() + { + return Config.Client.Graphics.AdvancedGraphics.brightnessMultiplier; + } + @Override + public void setBrightnessMultiplier(double newBrightnessMultiplier) + { + ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.brightnessMultiplier").value = newBrightnessMultiplier; + ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.brightnessMultiplier"); + } + + @Override + public double getSaturationMultiplier() + { + return Config.Client.Graphics.AdvancedGraphics.saturationMultiplier; + } + @Override + public void setSaturationMultiplier(double newSaturationMultiplier) + { + ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.saturationMultiplier").value = newSaturationMultiplier; + ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.saturationMultiplier"); + } } } diff --git a/core b/core index c9cabd8a3..bca2b6180 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c9cabd8a321a63cbd971bfae41b54d224feb43c2 +Subproject commit bca2b61800b613b630def131e9c9f85f9736493d From f66e27b077fd71fede8a3923c888fcb7b7ab9e52 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Thu, 10 Mar 2022 17:05:14 +0800 Subject: [PATCH 10/48] First version where 1.18.1 & 1.18.2 is merged --- 1.18.1.properties | 37 ++++++ 1.18.2.properties | 38 +++++++ build.gradle | 35 +++++- .../java/com/seibel/lod/common/Config.java | 5 + .../common/wrappers/chunk/ChunkWrapper.java | 5 + .../minecraft/MinecraftRenderWrapper.java | 5 + .../mimicObject/ChunkLoader.java | 106 ++++++++++++++---- .../mimicObject/LightedWorldGenRegion.java | 12 +- common/src/main/resources/lod.accesswidener | 2 +- .../mixins/events/MixinClientLevel.java | 11 ++ fabric/src/main/resources/fabric.mod.json | 4 +- forge/src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 43 ++----- 13 files changed, 236 insertions(+), 69 deletions(-) create mode 100644 1.18.1.properties create mode 100644 1.18.2.properties diff --git a/1.18.1.properties b/1.18.1.properties new file mode 100644 index 000000000..3fae30657 --- /dev/null +++ b/1.18.1.properties @@ -0,0 +1,37 @@ +# 1.18.1 version based stuff + +minecraft_version=1.18.1 +java_version = 17 + +# Fabric loader +fabric_loader_version=0.13.2 +fabric_api_version=0.46.4+1.18 + # Fabric mod versions + modmenu_version=3.0.1 + starlight_version_fabric=3554912 + lithium_version=mc1.18.1-0.7.7 + sodium_version=3605309 + iris_version=1.18.x-v1.1.4 + bclib_version=1.2.5 + immersive_portals_version = v1.0.4-1.18 + + # 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_sodium=1 + enable_lithium=0 + enable_iris=0 + enable_bclib=0 + +# Forge loader +forge_version=39.0.76 + # Forge mod versions + starlight_version_forge=3559934 + + # Forge mod run + # 0 = Dont 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 diff --git a/1.18.2.properties b/1.18.2.properties new file mode 100644 index 000000000..646007ceb --- /dev/null +++ b/1.18.2.properties @@ -0,0 +1,38 @@ +# 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 + +# Fabric loader +fabric_loader_version=0.13.3 +fabric_api_version=0.47.8+1.18.2 + # Fabric mod versions + modmenu_version=3.1.0 + starlight_version_fabric=3554912 + lithium_version=mc1.18.1-0.7.7 + sodium_version=3669187 + iris_version=1.18.x-v1.1.4 + bclib_version=1.2.5 + immersive_portals_version = v1.0.4-1.18 + + # 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_sodium=1 + enable_lithium=0 + enable_iris=0 + enable_bclib=0 + +# Forge loader +forge_version=40.0.1 + # Forge mod versions + starlight_version_forge=3559934 + + # Forge mod run + # 0 = Dont 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 diff --git a/build.gradle b/build.gradle index 94df09540..68d6ef3bc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ import io.github.ran.jarmerger.JarMergerPlugin + buildscript { dependencies{ classpath files('plugins/DHJarMerger-1.0.jar') @@ -11,6 +12,25 @@ plugins { id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false } +def loadProperties() { + def defaultMcVersion = '1.18.2' + if (!project.hasProperty("mcVer")) { + println "No mcVer set! Defaulting to ${defaultMcVersion}." + println "Tip: Use -PmcVer='${defaultMcVersion}' in cmd arg to set mcVer." + } + def mcVersion = project.hasProperty("mcVer") ? mcVer : defaultMcVersion + + println "Loading properties file at " + mcVersion + ".properties" + def props = new Properties() + props.load(new FileInputStream("$rootProject.rootDir/"+"$mcVersion"+".properties")) + + props.each { prop -> + rootProject.ext.set(prop.key, prop.value) + // println "Added prop [key:" + prop.key + ", value:" + prop.value + "]" + } +} +loadProperties() + apply plugin: JarMergerPlugin architectury { @@ -36,7 +56,7 @@ subprojects { p -> mappings loom.officialMojangMappings() //Manifold - annotationProcessor 'systems.manifold:manifold-preprocessor:2022.1.5' + annotationProcessor "systems.manifold:manifold-preprocessor:${rootProject.manifold_version}" // Toml implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") @@ -47,7 +67,6 @@ subprojects { p -> modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" } - if (p != project(":core")) { common(project(":core")) { transitive false } shadowMe(project(":core")) { transitive false } @@ -124,8 +143,11 @@ allprojects { p -> description: mod_description, homepage: mod_homepage, source: mod_source, - issues: mod_issues + issues: mod_issues, + minecraft_version: minecraft_version, + 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)" inputs.properties replaceProperties replaceProperties.put 'project', project @@ -150,11 +172,12 @@ allprojects { p -> tasks.withType(JavaCompile) { // Add Manifold Preprocessor - options.compilerArgs += ['-Xplugin:Manifold'] + def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") + options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] + // println options.compilerArgs if (p != project(":core")) { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - options.release = 17 + options.release = rootProject.java_version as Integer } } diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index 2260b6898..87ceec063 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -32,6 +32,11 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.I #define CONFIG +#if MC_VERSION_1.18.2 + +stafdqvsrevasbhyuicwegyhio + +#endif /** * This handles any configuration the user has access to. * @author coolGi2007 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 2cd61bd18..a7359bc08 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 @@ -66,8 +66,13 @@ public class ChunkWrapper implements IChunkWrapper @Override public IBiomeWrapper getBiome(int x, int y, int z) { + #if MC_VERSION_1_18_2 return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value()); + #elif MC_VERSION_1_18_1 + return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( + QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); + #endif } @Override 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 e54ad7d93..e7d8597ab 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 @@ -167,12 +167,17 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper pos = getMaximumRenderedChunks(); return pos; } + #define MC_VERSION_1_18_1 if (!usingBackupGetVanillaRenderedChunks) { try { LevelRenderer levelRenderer = MC.levelRenderer; LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; return (chunks.stream().map((chunk) -> { + #if MC_VERSION_1_18_2 AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); + #elif MC_VERSION_1_18_1 + AABB chunkBoundingBox = chunk.chunk.bb; + #endif return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), Math.floorDiv((int) chunkBoundingBox.minZ, 16)); }).collect(Collectors.toCollection(HashSet::new))); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index 8e6894e7d..b482312d7 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -5,16 +5,23 @@ import com.google.common.collect.Maps; import com.mojang.serialization.Codec; import com.mojang.serialization.Dynamic; import com.seibel.lod.core.api.ApiShared; +import com.seibel.lod.core.api.ClientApi; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; import java.util.Arrays; +import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Objects; +#if MC_VERSION_1_18_2 import net.minecraft.core.Holder; -import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; +#endif + +import net.minecraft.core.Registry; import net.minecraft.core.SectionPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -38,7 +45,6 @@ import net.minecraft.world.level.chunk.PalettedContainer; import net.minecraft.world.level.chunk.UpgradeData; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.blending.BlendingData; -import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext; @@ -70,11 +76,14 @@ public class ChunkLoader private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData) { Registry biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); -// Codec> biomeCodec = PalettedContainer.codec( -// biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS)); + #if MC_VERSION_1_18_1 + Codec> biomeCodec = PalettedContainer.codec( + biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS)); + #elif MC_VERSION_1_18_2 Codec>> biomeCodec = PalettedContainer.codec( biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS)); - + #endif + int i = level.getSectionsCount(); LevelChunkSection[] chunkSections = new LevelChunkSection[i]; @@ -90,18 +99,26 @@ public class ChunkLoader if (sectionId >= 0 && sectionId < chunkSections.length) { PalettedContainer blockStateContainer; + #if MC_VERSION_1_18_1 + PalettedContainer biomeContainer; + #elif MC_VERSION_1_18_2 PalettedContainer> biomeContainer; + #endif blockStateContainer = tagSection.contains("block_states", 10) ? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error) : new PalettedContainer(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES); + #if MC_VERSION_1_18_1 biomeContainer = tagSection.contains("biomes", 10) - ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string)).getOrThrow(false, LOGGER::error) - : new PalettedContainer>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); -// biomeContainer = tagSection.contains("biomes", 10) -// ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error) -// : new PalettedContainer>(biomes, biomes.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); + ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error) + : new PalettedContainer(biomes, biomes.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); + #elif MC_VERSION_1_18_2 + biomeContainer = tagSection.contains("biomes", 10) + ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string)).getOrThrow(false, LOGGER::error) + : new PalettedContainer>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); + #endif + chunkSections[sectionId] = new LevelChunkSection(sectionYPos, blockStateContainer, biomeContainer); } @@ -128,20 +145,66 @@ public class ChunkLoader } Heightmap.primeHeightmaps(chunk, ChunkStatus.FULL.heightmapsAfter()); } - - private static Map, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l) + + #if MC_VERSION_1_18_1 + private static Map, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l) { - Map, StructureStart> map = Maps.newHashMap(); - Registry> structStartRegistry = structurePieceSerializationContext.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); - CompoundTag compoundTag2 = compoundTag.getCompound("starts"); + HashMap, StructureStart> map = Maps.newHashMap(); + CompoundTag compoundTag2 = compoundTag.getCompound("starts"); for (String string : compoundTag2.getAllKeys()) { - ResourceLocation resourceLocation = ResourceLocation.tryParse(string); + String string2 = string.toLowerCase(Locale.ROOT); + StructureFeature structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2); + if (structureFeature == null) + { + LOGGER.error("Unknown structure start: {}", (Object) string2); + continue; + } + StructureStart structureStart = StructureFeature.loadStaticStart(structurePieceSerializationContext, compoundTag2.getCompound(string), l); + if (structureStart == null) + continue; + map.put(structureFeature, structureStart); + } + return map; + } + + private static Map, LongSet> unpackStructureReferences(ChunkPos chunkPos, CompoundTag compoundTag) + { + HashMap, LongSet> map = Maps.newHashMap(); + CompoundTag compoundTag2 = compoundTag.getCompound("References"); + for (String string : compoundTag2.getAllKeys()) + { + String string2 = string.toLowerCase(Locale.ROOT); + StructureFeature structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2); + if (structureFeature == null) + { + LOGGER.warn("Found reference to unknown structure '{}' in chunk {}, discarding", (Object) string2, (Object) chunkPos); + continue; + } + map.put(structureFeature, new LongOpenHashSet(Arrays.stream(compoundTag2.getLongArray(string)).filter(l -> + { + ChunkPos chunkPos2 = new ChunkPos(l); + if (chunkPos2.getChessboardDistance(chunkPos) > 8) + { + LOGGER.warn("Found invalid structure reference [ {} @ {} ] for chunk {}.", (Object) string2, (Object) chunkPos2, (Object) chunkPos); + return false; + } + return true; + }).toArray())); + } + return map; + } + #elif MC_VERSION_1_18_2 + private static Map, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l) { + Map, StructureStart> map = Maps.newHashMap(); + Registry> structStartRegistry = structurePieceSerializationContext.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); + CompoundTag compoundTag2 = compoundTag.getCompound("starts"); + for (String string : compoundTag2.getAllKeys()) { + ResourceLocation resourceLocation = ResourceLocation.tryParse(string); ConfiguredStructureFeature structureFeature = structStartRegistry.get(resourceLocation); // String string2 = string.toLowerCase(Locale.ROOT); // ConfiguredStructureFeature structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2); - if (structureFeature == null) - { + if (structureFeature == null) { LOGGER.error("Unknown structure start: {}", resourceLocation); continue; } @@ -152,7 +215,7 @@ public class ChunkLoader } return map; } - + private static Map, LongSet> unpackStructureReferences(RegistryAccess registryAccess, ChunkPos chunkPos, CompoundTag compoundTag) { Map, LongSet> map = Maps.newHashMap(); @@ -182,13 +245,14 @@ public class ChunkLoader } return map; } - + #endif + private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData) { CompoundTag tagStructures = chunkData.getCompound("structures"); chunk.setAllStarts( unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed())); - chunk.setAllReferences(unpackStructureReferences(level.registryAccess() ,chunk.getPos(), tagStructures)); + chunk.setAllReferences(unpackStructureReferences(#if MC_VERSION_1_18_2 level.registryAccess() ,#endif chunk.getPos(), tagStructures)); } private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData) 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 ea87fecfb..d754a6d0f 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 @@ -247,12 +247,20 @@ public class LightedWorldGenRegion extends WorldGenRegion { BlockTintCache blockTintCache = (BlockTintCache) this.tintCaches.get(colorResolver); return blockTintCache.getColor(blockPos); } + + private Biome _getBiome(BlockPos pos) { + #if MC_VERSION_1_18_2 + return getBiome(pos).value(); + #elif MC_VERSION_1_18_1 + return getBiome(pos); + #endif + } public int calculateBlockTint(BlockPos blockPos, ColorResolver colorResolver) { int i = (Minecraft.getInstance()).options.biomeBlendRadius; if (i == 0) - return colorResolver.getColor((Biome) getBiome(blockPos).value(), blockPos.getX(), blockPos.getZ()); + return colorResolver.getColor((Biome) _getBiome(blockPos), blockPos.getX(), blockPos.getZ()); int j = (i * 2 + 1) * (i * 2 + 1); int k = 0; int l = 0; @@ -262,7 +270,7 @@ public class LightedWorldGenRegion extends WorldGenRegion { while (cursor3D.advance()) { mutableBlockPos.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ()); - int n = colorResolver.getColor((Biome) getBiome((BlockPos) mutableBlockPos).value(), mutableBlockPos.getX(), mutableBlockPos.getZ()); + int n = colorResolver.getColor((Biome) _getBiome((BlockPos) mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ()); k += (n & 0xFF0000) >> 16; l += (n & 0xFF00) >> 8; m += n & 0xFF; diff --git a/common/src/main/resources/lod.accesswidener b/common/src/main/resources/lod.accesswidener index f568e46fe..564f2d77b 100644 --- a/common/src/main/resources/lod.accesswidener +++ b/common/src/main/resources/lod.accesswidener @@ -23,7 +23,7 @@ accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine L 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 field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder; accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess; #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 diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java index 7d6312a74..df7e92345 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java @@ -4,7 +4,9 @@ import com.seibel.lod.fabric.Main; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.renderer.LevelRenderer; +#if MC_VERSION_1_18_2 import net.minecraft.core.Holder; +#endif import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.dimension.DimensionType; @@ -19,12 +21,21 @@ import java.util.function.Supplier; * This class is used for world loading events * @author Ran */ + @Mixin(ClientLevel.class) public class MixinClientLevel { + #if MC_VERSION_1_18_2 @Inject(method = "", at = @At("TAIL")) private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, Holder holder, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) { Main.client_proxy.worldLoadEvent((ClientLevel) (Object) this); } + #elif MC_VERSION_1_18_1 + @Inject(method = "", at = @At("TAIL")) + private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, DimensionType dimensionType, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) { + Main.client_proxy.worldLoadEvent((ClientLevel) (Object) this); + } + #endif + @Inject(method = "setLightReady", at = @At("HEAD")) private void onChunkLightReady(int x, int z, CallbackInfo ci) { ClientLevel l = (ClientLevel) (Object) this; diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index dc95685e1..7f5921c3d 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -34,8 +34,8 @@ "depends": { "fabricloader": "*", "fabric": "*", - "minecraft": "1.18.2", - "java": ">=17" + "minecraft": "${minecraft_version}", + "java": ">=${java_version}" }, "suggests": { "another-mod": "*" diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index f51449c65..e3764750e 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,6 +1,6 @@ modLoader="javafml" #//mandatory -loaderVersion="[37,41)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[36,41)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. license="GNU GPLv3" issueTrackerURL="${issues}" diff --git a/gradle.properties b/gradle.properties index 61585837e..3498d0558 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,10 @@ org.gradle.jvmargs=-Xmx2048M -minecraft_version=1.18.2 - -archives_base_name=DistantHorizons -mod_version=1.6.2a maven_group=com.seibel.lod -toml_version=3.6.4 +archives_base_name=DistantHorizons # Mod info +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 @@ -15,35 +12,9 @@ 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 -# Fabric loader -fabric_loader_version=0.13.3 -fabric_api_version=0.47.8+1.18.2 - # Fabric mod versions - modmenu_version=3.1.0 - starlight_version_fabric=3554912 - lithium_version=mc1.18.1-0.7.7 - sodium_version=3669187 - iris_version=1.18.x-v1.1.4 - bclib_version=1.2.5 - immersive_portals_version = v1.0.4-1.18 +# Global Plugin versions +toml_version=3.6.4 +manifold_version=2022.1.5 - # 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_sodium=1 - enable_lithium=0 - enable_iris=0 - enable_bclib=0 - -# Forge loader -forge_version=40.0.1 - # Forge mod versions - starlight_version_forge=3559934 - - # Forge mod run - # 0 = Dont 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 +##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: +mcVer=1.18.1 \ No newline at end of file From 11910d0f283e886c170a75fe883d945d87f7aa69 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Thu, 10 Mar 2022 17:29:27 +0800 Subject: [PATCH 11/48] Fix IDE not reconising preprocessor --- build.gradle | 15 +++++++++++---- build.properties | 1 + .../main/java/com/seibel/lod/common/Config.java | 12 +----------- gradle.properties | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 build.properties diff --git a/build.gradle b/build.gradle index 68d6ef3bc..bbf15f9e7 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,11 @@ plugins { id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false } +def writeBuildGradlePredefine() { + def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") + new File(projectDir, "build.properties").text = "MC_VERSION_${excapedMCVersion}=\n" +} + def loadProperties() { def defaultMcVersion = '1.18.2' if (!project.hasProperty("mcVer")) { @@ -28,6 +33,7 @@ def loadProperties() { rootProject.ext.set(prop.key, prop.value) // println "Added prop [key:" + prop.key + ", value:" + prop.value + "]" } + writeBuildGradlePredefine() } loadProperties() @@ -170,11 +176,12 @@ allprojects { p -> tasks.withType(JavaCompile) { - // Add Manifold Preprocessor - def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") - options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] - +// def excapedMCVersion = rootProject.minecraft_version.replace(".", "_") +// options.compilerArgs += ['-Xplugin:Manifold', "-AMC_VERSION_${excapedMCVersion}"] +// + options.compilerArgs += ['-Xplugin:Manifold'] + // println options.compilerArgs if (p != project(":core")) { options.release = rootProject.java_version as Integer diff --git a/build.properties b/build.properties new file mode 100644 index 000000000..ae4f3e14a --- /dev/null +++ b/build.properties @@ -0,0 +1 @@ +MC_VERSION_1_18_2= diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index 87ceec063..4b3593810 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -29,21 +29,12 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.I import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator; - -#define CONFIG - -#if MC_VERSION_1.18.2 - -stafdqvsrevasbhyuicwegyhio - -#endif /** * This handles any configuration the user has access to. * @author coolGi2007 * @version 12-12-2021 */ -#if CONFIG public class Config //public class Config extends TinyConfig { @@ -296,5 +287,4 @@ public class Config } } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3498d0558..62d6d3038 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,4 @@ toml_version=3.6.4 manifold_version=2022.1.5 ##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: -mcVer=1.18.1 \ No newline at end of file +mcVer=1.18.2 \ No newline at end of file From b165726bc9b442c353f461ea4cfb824d1e370095 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Sun, 13 Mar 2022 15:26:24 +0800 Subject: [PATCH 12/48] Add new Config: BiomeBlending --- .gitmodules | 3 + .../java/com/seibel/lod/common/Config.java | 5 + .../wrappers/block/BlockDetailWrapper.java | 39 +++- .../block/TintGetterOverrideFast.java | 196 ++++++++++++++++ .../block/TintGetterOverrideSmooth.java | 219 ++++++++++++++++++ .../config/LodConfigWrapperSingleton.java | 11 + core | 2 +- 7 files changed, 470 insertions(+), 5 deletions(-) create mode 100644 common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideFast.java create mode 100644 common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java diff --git a/.gitmodules b/.gitmodules index 17c60bca6..4998a410e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "core"] path = core url = https://gitlab.com/jeseibel/distant-horizons-core.git +[submodule "Core"] + url = https://gitlab.com/jeseibel/distant-horizons-core + branch = main diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index 4b3593810..25c7f4f0f 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -124,6 +124,11 @@ public class Config public static String _dropoffQuality = IQuality.DROPOFF_QUALITY_DESC; @ConfigAnnotations.Entry public static DropoffQuality dropoffQuality = IQuality.DROPOFF_QUALITY_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_DESC; + @ConfigAnnotations.Entry(minValue = 0, maxValue = 7) + public static int lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_MIN_DEFAULT_MAX.defaultValue; } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java index 8b4ff8bf2..ec1d004ad 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java @@ -2,34 +2,58 @@ package com.seibel.lod.common.wrappers.block; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.Random; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Stream; +import com.seibel.lod.common.Config; import com.seibel.lod.common.wrappers.McObjectConverter; import com.seibel.lod.common.wrappers.chunk.ChunkWrapper; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.enums.LodDirection; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.util.ColorUtil; import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.minecraft.Util; import net.minecraft.client.Minecraft; +import net.minecraft.client.color.block.BlockTintCache; +import net.minecraft.client.renderer.BiomeColors; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; +import net.minecraft.core.Cursor3D; import net.minecraft.core.Direction; -import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.*; +import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.FlowerBlock; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; public class BlockDetailWrapper extends IBlockDetailWrapper { + private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); + public static final int FLOWER_COLOR_SCALE = 5; public static final Random random = new Random(0); @@ -195,7 +219,7 @@ public class BlockDetailWrapper extends IBlockDetailWrapper double zWidth = (bbox.maxZ - bbox.minZ); noFullFace = xWidth < 1 && zWidth < 1 && yWidth < 1; } - } else { // Liquad Block + } else { // Liquid Block dontOccludeFaces = new boolean[6]; } isShapeResolved = true; @@ -232,7 +256,14 @@ public class BlockDetailWrapper extends IBlockDetailWrapper isColorResolved = true; } - + private BlockAndTintGetter wrapColorResolver(LevelReader level) { + int blendDistance = CONFIG.client().graphics().quality().getLodBiomeBlending(); + if (blendDistance == 0) { + return new TintGetterOverrideFast(level); + } else { + return new TintGetterOverrideSmooth(level, blendDistance); + } + } @Override public int getAndResolveFaceColor(LodDirection dir, IChunkWrapper chunk, AbstractBlockPosWrapper blockPos) @@ -241,7 +272,7 @@ public class BlockDetailWrapper extends IBlockDetailWrapper resolveColors(); if (!needPostTinting) return baseColor; int tintColor = Minecraft.getInstance().getBlockColors() - .getColor(state, ((ChunkWrapper)chunk).getColorResolver(), + .getColor(state, wrapColorResolver(((ChunkWrapper)chunk).getColorResolver()), McObjectConverter.Convert(blockPos), tintIndex); if (tintColor == -1) return baseColor; return ColorUtil.multiplyARGBwithRGB(baseColor, tintColor); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideFast.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideFast.java new file mode 100644 index 000000000..8be87ce91 --- /dev/null +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideFast.java @@ -0,0 +1,196 @@ +package com.seibel.lod.common.wrappers.block; + +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.minecraft.Util; +import net.minecraft.client.color.block.BlockTintCache; +import net.minecraft.client.renderer.BiomeColors; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Cursor3D; +import net.minecraft.core.Direction; +import net.minecraft.world.level.*; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; +import java.util.stream.Stream; + +public class TintGetterOverrideFast implements BlockAndTintGetter { + LevelReader parent; + private final Object2ObjectArrayMap> tintCaches; + + public TintGetterOverrideFast(LevelReader parent) { + this.parent = parent; + this.tintCaches = Util.make(new Object2ObjectArrayMap(3), object2ObjectArrayMap -> { + object2ObjectArrayMap.put(BiomeColors.GRASS_COLOR_RESOLVER, new ConcurrentHashMap()); + object2ObjectArrayMap.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new ConcurrentHashMap()); + object2ObjectArrayMap.put(BiomeColors.WATER_COLOR_RESOLVER, new ConcurrentHashMap()); + }); + } + + private Biome _getBiome(BlockPos pos) { + #if MC_VERSION_1_18_2 + return parent.getBiome(pos).value(); + #elif MC_VERSION_1_18_1 + return parent.getBiome(pos); + #endif + } + + @Override + public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) { + Biome b = _getBiome(blockPos); + return tintCaches.get(colorResolver).computeIfAbsent(b, (key) -> colorResolver.getColor(b, blockPos.getX(), blockPos.getZ())); + } + + @Override + public float getShade(Direction direction, boolean bl) { + return parent.getShade(direction, bl); + } + + @Override + public LevelLightEngine getLightEngine() { + return parent.getLightEngine(); + } + + @Override + public int getBrightness(LightLayer lightLayer, BlockPos blockPos) { + return parent.getBrightness(lightLayer, blockPos); + } + + @Override + public int getRawBrightness(BlockPos blockPos, int i) { + return parent.getRawBrightness(blockPos, i); + } + + @Override + public boolean canSeeSky(BlockPos blockPos) { + return parent.canSeeSky(blockPos); + } + + @Override + @Nullable + public BlockEntity getBlockEntity(BlockPos blockPos) { + return parent.getBlockEntity(blockPos); + } + + @Override + public Optional getBlockEntity(BlockPos blockPos, BlockEntityType blockEntityType) { + return parent.getBlockEntity(blockPos, blockEntityType); + } + + @Override + public BlockState getBlockState(BlockPos blockPos) { + return parent.getBlockState(blockPos); + } + + @Override + public FluidState getFluidState(BlockPos blockPos) { + return parent.getFluidState(blockPos); + } + + @Override + public int getLightEmission(BlockPos blockPos) { + return parent.getLightEmission(blockPos); + } + + @Override + public int getMaxLightLevel() { + return parent.getMaxLightLevel(); + } + + @Override + public Stream getBlockStates(AABB aABB) { + return parent.getBlockStates(aABB); + } + + @Override + public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) { + return parent.isBlockInLine(clipBlockStateContext); + } + + @Override + public BlockHitResult clip(ClipContext clipContext) { + return parent.clip(clipContext); + } + + @Override + @Nullable + public BlockHitResult clipWithInteractionOverride(Vec3 vec3, Vec3 vec32, BlockPos blockPos, VoxelShape voxelShape, BlockState blockState) { + return parent.clipWithInteractionOverride(vec3, vec32, blockPos, voxelShape, blockState); + } + + @Override + public double getBlockFloorHeight(VoxelShape voxelShape, Supplier supplier) { + return parent.getBlockFloorHeight(voxelShape, supplier); + } + + @Override + public double getBlockFloorHeight(BlockPos blockPos) { + return parent.getBlockFloorHeight(blockPos); + } + + @Override + public int getHeight() { + return parent.getHeight(); + } + + @Override + public int getMinBuildHeight() { + return parent.getMinBuildHeight(); + } + + @Override + public int getMaxBuildHeight() { + return parent.getMaxBuildHeight(); + } + + @Override + public int getSectionsCount() { + return parent.getSectionsCount(); + } + + @Override + public int getMinSection() { + return parent.getMinSection(); + } + + @Override + public int getMaxSection() { + return parent.getMaxSection(); + } + + @Override + public boolean isOutsideBuildHeight(BlockPos blockPos) { + return parent.isOutsideBuildHeight(blockPos); + } + + @Override + public boolean isOutsideBuildHeight(int i) { + return parent.isOutsideBuildHeight(i); + } + + @Override + public int getSectionIndex(int i) { + return parent.getSectionIndex(i); + } + + @Override + public int getSectionIndexFromSectionY(int i) { + return parent.getSectionIndexFromSectionY(i); + } + + @Override + public int getSectionYFromSectionIndex(int i) { + return parent.getSectionYFromSectionIndex(i); + } +} diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java new file mode 100644 index 000000000..760f35aad --- /dev/null +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/TintGetterOverrideSmooth.java @@ -0,0 +1,219 @@ +package com.seibel.lod.common.wrappers.block; + +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.minecraft.Util; +import net.minecraft.client.color.block.BlockTintCache; +import net.minecraft.client.renderer.BiomeColors; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Cursor3D; +import net.minecraft.core.Direction; +import net.minecraft.world.level.*; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; +import java.util.function.Supplier; +import java.util.stream.Stream; + +public class TintGetterOverrideSmooth implements BlockAndTintGetter { + LevelReader parent; + private final Object2ObjectArrayMap tintCaches; + public int smoothingRange; + + public TintGetterOverrideSmooth(LevelReader parent, int smoothingRange) { + this.parent = parent; + this.smoothingRange = smoothingRange; + this.tintCaches = Util.make(new Object2ObjectArrayMap(3), object2ObjectArrayMap -> { + object2ObjectArrayMap.put(BiomeColors.GRASS_COLOR_RESOLVER, new BlockTintCache((pos) -> calculateBlockTint(pos, BiomeColors.GRASS_COLOR_RESOLVER))); + object2ObjectArrayMap.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache((pos) -> calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER))); + object2ObjectArrayMap.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache((pos) -> calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER))); + }); + } + + private Biome _getBiome(BlockPos pos) { + #if MC_VERSION_1_18_2 + return parent.getBiome(pos).value(); + #elif MC_VERSION_1_18_1 + return parent.getBiome(pos); + #endif + } + + public int calculateBlockTint(BlockPos blockPos, ColorResolver colorResolver) + { + int i = smoothingRange; + if (i == 0) + return colorResolver.getColor(_getBiome(blockPos), blockPos.getX(), blockPos.getZ()); + int j = (i * 2 + 1) * (i * 2 + 1); + int k = 0; + int l = 0; + int m = 0; + Cursor3D cursor3D = new Cursor3D(blockPos.getX() - i, blockPos.getY(), blockPos.getZ() - i, blockPos.getX() + i, blockPos.getY(), blockPos.getZ() + i); + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + while (cursor3D.advance()) + { + mutableBlockPos.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ()); + int n = colorResolver.getColor(_getBiome(mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ()); + k += (n & 0xFF0000) >> 16; + l += (n & 0xFF00) >> 8; + m += n & 0xFF; + } + return (k / j & 0xFF) << 16 | (l / j & 0xFF) << 8 | m / j & 0xFF; + } + + @Override + public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) { + BlockTintCache blockTintCache = this.tintCaches.get(colorResolver); + return blockTintCache.getColor(blockPos); + } + + @Override + public float getShade(Direction direction, boolean bl) { + return parent.getShade(direction, bl); + } + + @Override + public LevelLightEngine getLightEngine() { + return parent.getLightEngine(); + } + + @Override + public int getBrightness(LightLayer lightLayer, BlockPos blockPos) { + return parent.getBrightness(lightLayer, blockPos); + } + + @Override + public int getRawBrightness(BlockPos blockPos, int i) { + return parent.getRawBrightness(blockPos, i); + } + + @Override + public boolean canSeeSky(BlockPos blockPos) { + return parent.canSeeSky(blockPos); + } + + @Override + @Nullable + public BlockEntity getBlockEntity(BlockPos blockPos) { + return parent.getBlockEntity(blockPos); + } + + @Override + public Optional getBlockEntity(BlockPos blockPos, BlockEntityType blockEntityType) { + return parent.getBlockEntity(blockPos, blockEntityType); + } + + @Override + public BlockState getBlockState(BlockPos blockPos) { + return parent.getBlockState(blockPos); + } + + @Override + public FluidState getFluidState(BlockPos blockPos) { + return parent.getFluidState(blockPos); + } + + @Override + public int getLightEmission(BlockPos blockPos) { + return parent.getLightEmission(blockPos); + } + + @Override + public int getMaxLightLevel() { + return parent.getMaxLightLevel(); + } + + @Override + public Stream getBlockStates(AABB aABB) { + return parent.getBlockStates(aABB); + } + + @Override + public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) { + return parent.isBlockInLine(clipBlockStateContext); + } + + @Override + public BlockHitResult clip(ClipContext clipContext) { + return parent.clip(clipContext); + } + + @Override + @Nullable + public BlockHitResult clipWithInteractionOverride(Vec3 vec3, Vec3 vec32, BlockPos blockPos, VoxelShape voxelShape, BlockState blockState) { + return parent.clipWithInteractionOverride(vec3, vec32, blockPos, voxelShape, blockState); + } + + @Override + public double getBlockFloorHeight(VoxelShape voxelShape, Supplier supplier) { + return parent.getBlockFloorHeight(voxelShape, supplier); + } + + @Override + public double getBlockFloorHeight(BlockPos blockPos) { + return parent.getBlockFloorHeight(blockPos); + } + + @Override + public int getHeight() { + return parent.getHeight(); + } + + @Override + public int getMinBuildHeight() { + return parent.getMinBuildHeight(); + } + + @Override + public int getMaxBuildHeight() { + return parent.getMaxBuildHeight(); + } + + @Override + public int getSectionsCount() { + return parent.getSectionsCount(); + } + + @Override + public int getMinSection() { + return parent.getMinSection(); + } + + @Override + public int getMaxSection() { + return parent.getMaxSection(); + } + + @Override + public boolean isOutsideBuildHeight(BlockPos blockPos) { + return parent.isOutsideBuildHeight(blockPos); + } + + @Override + public boolean isOutsideBuildHeight(int i) { + return parent.isOutsideBuildHeight(i); + } + + @Override + public int getSectionIndex(int i) { + return parent.getSectionIndex(i); + } + + @Override + public int getSectionIndexFromSectionY(int i) { + return parent.getSectionIndexFromSectionY(i); + } + + @Override + public int getSectionYFromSectionIndex(int i) { + return parent.getSectionYFromSectionIndex(i); + } +} diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 789c7e686..6bc9ce8f3 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -195,6 +195,17 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.dropoffQuality").value = newDropoffQuality; ConfigGui.editSingleOption.saveOption("client.graphics.quality.dropoffQuality"); } + + @Override + public int getLodBiomeBlending() { + return Config.Client.Graphics.Quality.lodBiomeBlending; + } + + @Override + public void setLodBiomeBlending(int newLodBiomeBlending) { + ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodBiomeBlending").value = newLodBiomeBlending; + ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodBiomeBlending"); + } } diff --git a/core b/core index c9cabd8a3..8a1d3c2d3 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c9cabd8a321a63cbd971bfae41b54d224feb43c2 +Subproject commit 8a1d3c2d3f3ed1e4fbb1ef2fce655e9aa0a58152 From 82449c5edc8e6b6f11f7b7541ebe49cf63e648cf Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Sun, 13 Mar 2022 15:40:08 +0800 Subject: [PATCH 13/48] Update and fix core branch tracking(I think?) --- .gitmodules | 1 + core | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 4998a410e..1fb3b4191 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "core"] path = core url = https://gitlab.com/jeseibel/distant-horizons-core.git + branch = main [submodule "Core"] url = https://gitlab.com/jeseibel/distant-horizons-core branch = main diff --git a/core b/core index 8a1d3c2d3..1c7d87b9d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 8a1d3c2d3f3ed1e4fbb1ef2fce655e9aa0a58152 +Subproject commit 1c7d87b9d3ebfffad683771ff48ce88364309327 From ed82480c89f6386b24c77aa51a7f48c532d26b15 Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Sun, 13 Mar 2022 07:41:53 +0000 Subject: [PATCH 14/48] Update .gitmodules properly this time --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1fb3b4191..c47aed1da 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,6 +2,3 @@ path = core url = https://gitlab.com/jeseibel/distant-horizons-core.git branch = main -[submodule "Core"] - url = https://gitlab.com/jeseibel/distant-horizons-core - branch = main From b4a5da4a7469a463b3094424361ee8ebd8c70dc6 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Sun, 13 Mar 2022 16:15:29 +0800 Subject: [PATCH 15/48] Update Config defaults --- build.properties | 2 +- gradle.properties | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index ae4f3e14a..f059b81db 100644 --- a/build.properties +++ b/build.properties @@ -1 +1 @@ -MC_VERSION_1_18_2= +MC_VERSION_1_18_1= diff --git a/gradle.properties b/gradle.properties index 62d6d3038..736b8a929 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ org.gradle.jvmargs=-Xmx2048M +org.gradle.daemon=false maven_group=com.seibel.lod archives_base_name=DistantHorizons @@ -17,4 +18,4 @@ toml_version=3.6.4 manifold_version=2022.1.5 ##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: -mcVer=1.18.2 \ No newline at end of file +mcVer=1.18.1 \ No newline at end of file From 62ab450d984dc3de19099c0e92ff73a9a1de3aa9 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Sun, 13 Mar 2022 16:16:29 +0800 Subject: [PATCH 16/48] Update Core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 1c7d87b9d..49cc46dc2 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 1c7d87b9d3ebfffad683771ff48ce88364309327 +Subproject commit 49cc46dc25b1307e3e1fc8f2d13a9288c33674f8 From 9a1e6e29d400f46c5567d7e4784f2cd64f93ad60 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Sun, 13 Mar 2022 16:45:41 +0800 Subject: [PATCH 17/48] Update Readme.md on switching versions --- Readme.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index b4b5e06e1..801747962 100644 --- a/Readme.md +++ b/Readme.md @@ -17,12 +17,12 @@ If you want to see a quick demo, check out a video covering the mod here: Architectury version: 3.4-SNAPSHOT\ Forge version: 39.0.5 and 38.0.14\ Fabric version: 0.13.2\ -Fabric API version: 0.44.0+1.18 - -Modmenu version: 3.0.1 +Fabric API version: 0.44.0+1.18\ +Modmenu version: 3.0.1\ +Java Compiler plugin: Manifold Preprocessor Notes:\ -This version has been confirmed to work in Eclipse and Retail Minecraft.\ +This version has been confirmed to work in IDE and Retail Minecraft.\ (Retail running forge version 1.18.1-39.0.5 and fabric version 1.18-0.12.12 and 1.18.1-0.13.2) @@ -35,19 +35,29 @@ https://fabricmc.net/wiki/tutorial:setup * A Java Development Kit (JDK) for Java 17 (recommended) or newer. Visit https://www.oracle.com/java/technologies/downloads/ for installers. * Git or someway to clone git projects. Visit https://git-scm.com/ for installers. -* (Not required) Any Java IDE, for example Intellij IDEA and Eclipse. You may also use any other code editors, such as Visual Studio Code. (Optional) -It's better to use IntelliJ IDEA since Eclipse is not supported by Architectury, but it still works. +* (Not required) Any Java IDE with plugins that support Manifold, for example Intellij IDEA. **If using IntelliJ:** +0. Install Manifold plugin 1. open IDEA and import the build.gradle 2. refresh the Gradle project in IDEA if required -**If using Ecplise:** +**If using Ecplise: (Note that Eclispe currently doesn't support Manifold's preprocessor!)** 1. run the command: `./gradlew geneclipseruns` 2. run the command: `./gradlew eclipse` 3. Make sure eclipse has the JDK 17 installed. (This is needed so that eclipse can run minecraft) 4. Import the project into eclipse +## Switching Versions +This branch support 2 built versions: + - 1.18.2 + - 1.18.1 (which also runs on 1.18) + +To switch between active versions, change `mcVer=1.18.?` in `gradle.properties` file. + +If running on IDE, to ensure IDE pickup the changed versions, you will need to run a gradle command again to allow gradle to update all the libs. (In IntellJ you will also need to do a gradle sync again if it didn't start it automatically.) +>Note: There may be a `java.nio.file.FileSystemException` thrown on running the command after switching versions. To fix it, either restart your IDE (as your IDE is locking up a file) or use tools like LockHunter to unlock the linked file. (Often a lib file under `common\build\lib` or `forge\build\lib` or `fabric\build\lib`). If anyone knows how to solve this issue please comment to this issue: https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues/233 + ## Compiling **Using GUI** @@ -62,8 +72,9 @@ It's better to use IntelliJ IDEA since Eclipse is not supported by Architectury, 1. `git clone -b 1.18.X --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git` 2. `cd minecraft-lod-mod` 3. `./gradlew assemble` -5. `./gradlew mergeJars` -6. The compiled jar file will be in the folder `Merged` +4. `./gradlew mergeJars` +5. The compiled jar file will be in the folder `Merged` +>Note: You can add the arg: `-PmcVer=1.18.?` to tell gradle to build a selected MC version instead of having to manually modify the `gradle.properties` file. ## Other commands From eefad5e0524fb0246ed8d1a395d7572ac533eebe Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Sun, 13 Mar 2022 22:57:07 +0800 Subject: [PATCH 18/48] Improved getMaximumRenderedChunk and fix GLMessage on forge --- .../seibel/lod/common/wrappers/world/WorldWrapper.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java index c944503af..1b55a87fd 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java @@ -36,6 +36,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkSource; import net.minecraft.world.level.chunk.ChunkStatus; import org.jetbrains.annotations.Nullable; @@ -175,5 +176,12 @@ public class WorldWrapper implements IWorldWrapper return new ChunkWrapper(chunk, world); } + @Override + public boolean hasChunkLoaded(int chunkX, int chunkZ) { + // world.hasChunk(chunkX, chunkZ); THIS DOES NOT WORK FOR CLIENT LEVEL CAUSE MOJANG ALWAYS RETURN TRUE FOR THAT! + ChunkSource source = world.getChunkSource(); + return source.hasChunk(chunkX, chunkZ); + } + } From 7c8ac0c2ff9c3c5957645269cb3ca88ef94de851 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Sun, 13 Mar 2022 22:57:42 +0800 Subject: [PATCH 19/48] Fix mistakes + update core --- .../lod/common/wrappers/minecraft/MinecraftRenderWrapper.java | 3 +-- core | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) 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 e7d8597ab..6696cb6b9 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 @@ -150,7 +150,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper *

*/ - public boolean usingBackupGetVanillaRenderedChunks = false; + public boolean usingBackupGetVanillaRenderedChunks = true; @Override public HashSet getVanillaRenderedChunks() { @@ -167,7 +167,6 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper pos = getMaximumRenderedChunks(); return pos; } - #define MC_VERSION_1_18_1 if (!usingBackupGetVanillaRenderedChunks) { try { LevelRenderer levelRenderer = MC.levelRenderer; diff --git a/core b/core index 49cc46dc2..fbd8f4843 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 49cc46dc25b1307e3e1fc8f2d13a9288c33674f8 +Subproject commit fbd8f48433749607b38789b597f7a7c12425faff From ebbf304c946d96c0166ecc69fe4f2c4c0d12d762 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Mon, 14 Mar 2022 15:10:20 +0800 Subject: [PATCH 20/48] Updated core --- .../lod/common/wrappers/chunk/ChunkWrapper.java | 17 +++++++++++++++++ core | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) 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 a7359bc08..89344bb12 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 @@ -1,5 +1,6 @@ package com.seibel.lod.common.wrappers.chunk; +import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.util.LevelPosUtil; import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; @@ -83,6 +84,22 @@ public class ChunkWrapper implements IChunkWrapper return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; } + @Override + public BlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir) { + int fy = y+dir.getNormal().y; + if (fy < getMinBuildHeight() || fy > getMaxBuildHeight()) return null; + BlockPos pos = new BlockPos(x+dir.getNormal().x,fy,z+dir.getNormal().z); + BlockState blockState; + if (blockPosInsideChunk(x,y,z)) + blockState = chunk.getBlockState(pos); + else { + blockState = lightSource.getBlockState(pos); + } + if (blockState == null || blockState.isAir()) return null; + BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; + } + public ChunkAccess getChunk() { return chunk; } diff --git a/core b/core index fbd8f4843..7da2b9061 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit fbd8f48433749607b38789b597f7a7c12425faff +Subproject commit 7da2b90611790b680dbe271ea66e608b84d9229b From 9530eea287acfde352d20fedb66bccfc67937416 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Mon, 14 Mar 2022 16:23:04 +0800 Subject: [PATCH 21/48] Update core and fix serverRenderDistanceMax not being checked --- .../lod/common/wrappers/minecraft/MinecraftRenderWrapper.java | 3 +-- core | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) 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 6696cb6b9..34612ce19 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 @@ -24,7 +24,6 @@ import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; import com.seibel.lod.common.wrappers.McObjectConverter; @@ -130,7 +129,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper @Override public int getRenderDistance() { - return MC.options.renderDistance; + return MC.options.getEffectiveRenderDistance(); } @Override diff --git a/core b/core index 7da2b9061..d2056d824 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 7da2b90611790b680dbe271ea66e608b84d9229b +Subproject commit d2056d824f5cb7aa6b40aa747b8e2de7c06cd8a8 From 5f48b416938346313e990c7ab8d4595e4b922640 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Tue, 15 Mar 2022 00:00:36 +0800 Subject: [PATCH 22/48] Add Advanced Fog config entries. Actual impl is a todo. --- .../java/com/seibel/lod/common/Config.java | 80 ++++++++++ .../config/LodConfigWrapperSingleton.java | 151 +++++++++++++++++- core | 2 +- 3 files changed, 231 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index 25c7f4f0f..e3f0e8306 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -25,6 +25,8 @@ import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.*; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog.IHeightFog; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator; @@ -153,6 +155,84 @@ public class Config public static String _disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DESC; @ConfigAnnotations.Entry public static boolean disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DEFAULT; + + @ConfigAnnotations.ScreenEntry + public static AdvancedFog advancedFog; + + public static class AdvancedFog { + static final double SQRT2 = 1.4142135623730951; + + @ConfigAnnotations.FileComment + public static String _farFogStart = IAdvancedFog.FAR_FOG_START_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double farFogStart = IAdvancedFog.FAR_FOG_START_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogEnd = IAdvancedFog.FAR_FOG_END_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double farFogEnd = IAdvancedFog.FAR_FOG_END_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogMin = IAdvancedFog.FAR_FOG_MIN_DESC; + @ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2) + public static double farFogMin = IAdvancedFog.FAR_FOG_MIN_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogMax = IAdvancedFog.FAR_FOG_MAX_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0) + public static double farFogMax = IAdvancedFog.FAR_FOG_MAX_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogType = IAdvancedFog.FAR_FOG_TYPE_DESC; + @ConfigAnnotations.Entry + public static FogSetting.Type farFogType = IAdvancedFog.FAR_FOG_TYPE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_DESC; + @ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0) + public static double farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.ScreenEntry + public static HeightFog HeightFog; + + public static class HeightFog { + + @ConfigAnnotations.FileComment + public static String _heightFogTMode = IHeightFog.HEIGHT_FOG_MODE_DESC; + @ConfigAnnotations.Entry + public static HeightFogMode heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _heightFogStart = IHeightFog.HEIGHT_FOG_START_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double heightFogStart = IHeightFog.HEIGHT_FOG_START_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogEnd = IHeightFog.HEIGHT_FOG_END_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double heightFogEnd = IHeightFog.HEIGHT_FOG_END_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogMin = IHeightFog.HEIGHT_FOG_MIN_DESC; + @ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2) + public static double heightFogMin = IHeightFog.HEIGHT_FOG_MIN_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogMax = IHeightFog.HEIGHT_FOG_MAX_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0) + public static double heightFogMax = IHeightFog.HEIGHT_FOG_MAX_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DESC; + @ConfigAnnotations.Entry + public static FogSetting.Type heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_DESC; + @ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0) + public static double heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; + } + } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 6bc9ce8f3..57299f134 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -3,7 +3,6 @@ package com.seibel.lod.common.wrappers.config; import com.seibel.lod.core.enums.config.*; import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.common.Config; /** @@ -211,6 +210,13 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton public static class FogQuality implements IFogQuality { + public final IAdvancedFog advancedFog; + + FogQuality() + { + advancedFog = new AdvancedFog(); + } + @Override public FogDistance getFogDistance() { @@ -263,6 +269,149 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.disableVanillaFog").value = newDisableVanillaFog; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.disableVanillaFog"); } + + @Override + public IAdvancedFog advancedFog() { + return advancedFog; + } + + public static class AdvancedFog implements IAdvancedFog { + public final IHeightFog heightFog; + + public AdvancedFog() { + heightFog = new HeightFog(); + } + + @Override + public double getFarFogStart() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogStart; + } + @Override + public double getFarFogEnd() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogEnd; + } + @Override + public double getFarFogMin() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMin; + } + @Override + public double getFarFogMax() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax; + } + @Override + public FogSetting.Type getFarFogType() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogType; + } + @Override + public double getFarFogDensity() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogDensity; + } + + @Override + public void setFarFogStart(double newFarFogStart) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogStart").value = newFarFogStart; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogStart"); + } + @Override + public void setFarFogEnd(double newFarFogEnd) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogEnd").value = newFarFogEnd; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogEnd"); + } + @Override + public void setFarFogMin(double newFarFogMin) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMin").value = newFarFogMin; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMin"); + } + @Override + public void setFarFogMax(double newFarFogMax) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMax").value = newFarFogMax; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMax"); + } + @Override + public void setFarFogType(FogSetting.Type newFarFogType) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogType").value = newFarFogType; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogType"); + } + @Override + public void setFarFogDensity(double newFarFogDensity) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogDensity").value = newFarFogDensity; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogDensity"); + } + + @Override + public IHeightFog heightFog() { + return heightFog; + } + + public static class HeightFog implements IHeightFog { + + @Override + public HeightFogMode getHeightFogMode() { + return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMode; + } + @Override + public double getHeightFogStart() { + return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogStart; + } + @Override + public double getHeightFogEnd() { + return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogEnd; + } + @Override + public double getHeightFogMin() { + return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMin; + } + @Override + public double getHeightFogMax() { + return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMax; + } + @Override + public FogSetting.Type getHeightFogType() { + return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogType; + } + @Override + public double getHeightFogDensity() { + return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogDensity; + } + + @Override + public void setHeightFogType(HeightFogMode newHeightFogMode) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode").value = newHeightFogMode; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode"); + } + @Override + public void setHeightFogStart(double newHeightFogStart) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart").value = newHeightFogStart; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart"); + } + @Override + public void setHeightFogEnd(double newHeightFogEnd) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd").value = newHeightFogEnd; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd"); + } + @Override + public void setHeightFogMin(double newHeightFogMin) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin").value = newHeightFogMin; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin"); + } + @Override + public void setHeightFogMax(double newHeightFogMax) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax").value = newHeightFogMax; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax"); + } + @Override + public void setHeightFogType(FogSetting.Type newHeightFogType) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogType").value = newHeightFogType; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogType"); + } + @Override + public void setHeightFogDensity(double newHeightFogDensity) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity").value = newHeightFogDensity; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity"); + } + } + } + } diff --git a/core b/core index d2056d824..1c0e7839c 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d2056d824f5cb7aa6b40aa747b8e2de7c06cd8a8 +Subproject commit 1c0e7839c066ed96754de3f46186a240dd7fcc66 From 5cc31efa12c761246a6100ea272cedeb7d2c35fa Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 02:16:04 +0000 Subject: [PATCH 23/48] Attempt to add 1.18.1 and 1.18.2 auto building --- .gitlab-ci.yml | 83 ++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 54 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f2dfb293..24ad33801 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,8 +4,8 @@ image: gradle:eclipse-temurin # all stages need to be defined here stages: - gradleSetup - - build - - merge + - build_18-1 + - build_18-2 variables: # Disable the Gradle daemon for Continuous Integration servers as correctness @@ -25,7 +25,6 @@ before_script: -# first stage # This prevents us from re-downloading Gradle every stage gradleSetup: stage: gradleSetup @@ -42,71 +41,47 @@ gradleSetup: -# second stage -build: - stage: build - script: ./gradlew build --gradle-user-home cache/ +# 1.18.1 build +build_18-1: + stage: build_18-1 + script: ./gradlew build -PmcVer=1.18.1 --gradle-user-home cache/; ./gradlew merge --gradle-user-home cache/ # build using Java 17 image: eclipse-temurin:17 cache: - key: "$CI_COMMIT_REF_NAME" + key: "$CI_COMMIT_REF_NAME_18-1" policy: pull-push paths: - - .architectury-transformer - - .gradle - - build - - common/.gradle - - common/build - - core/.gradle - - core/build - - fabric/.gradle - - fabric/src/generated - - forge/.gradle - - forge/src/generated - - build - .gradle - cache/ artifacts: - name: "NightlyBuild-$CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" - paths: - # relative to the root directory - - fabric/build/libs - - forge/build/libs - exclude: - - fabric/build/libs/*-dev.jar - - fabric/build/libs/*-dev-shadow.jar - - fabric/build/libs/*-sources-dev.jar - - fabric/build/libs/*-sources.jar - - forge/build/libs/*-dev.jar - - forge/build/libs/*-dev-shadow.jar - - forge/build/libs/*-sources-dev.jar - - forge/build/libs/*-sources.jar - reports: - # To ensure we've access to these files in the next stage - dotenv: generate_jars.env - expire_in: 1 day - -# third stage -merge: - stage: merge - script: ./gradlew merge --gradle-user-home cache/ - # build using Java 17 - image: eclipse-temurin:17 - cache: - key: "$CI_COMMIT_REF_NAME" - policy: pull-push - paths: - - build - - .gradle - - cache/ - artifacts: - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" paths: # relative to the root directory - Merged expire_in: 1 day +# 1.18.2 build +build_18-2: + stage: build_18-2 + script: ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/; ./gradlew merge --gradle-user-home cache/ + # build using Java 17 + image: eclipse-temurin:17 + cache: + key: "$CI_COMMIT_REF_NAME_18-2" + policy: pull-push + paths: + - .gradle + - cache/ + artifacts: + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" + paths: + # relative to the root directory + - Merged + expire_in: 1 day + + + ## - stage #deploy: # stage: deploy From 919990820e97899c59568a8e82449ca4235cee66 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 02:43:12 +0000 Subject: [PATCH 24/48] Fix exporting duplicate jars --- .gitlab-ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24ad33801..d5d4ada14 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,12 +53,6 @@ build_18-1: paths: - .gradle - cache/ - artifacts: - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" - paths: - # relative to the root directory - - Merged - expire_in: 1 day # 1.18.2 build @@ -74,7 +68,8 @@ build_18-2: - .gradle - cache/ artifacts: - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" + # This should only be done for the last build, otherwise there will be a number of duplicate jars + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" paths: # relative to the root directory - Merged From ec32d09468f4e3cb13c11de0b5713e7a58faacba Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 02:51:39 +0000 Subject: [PATCH 25/48] Try separating the archiving into a separate step This will make adding/removing MC versions to compile easier --- .gitlab-ci.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5d4ada14..b95b3fdc1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,13 +6,11 @@ stages: - gradleSetup - build_18-1 - build_18-2 + - archive variables: - # Disable the Gradle daemon for Continuous Integration servers as correctness - # is usually a priority over speed in CI environments. Using a fresh - # runtime for each build is more reliable since the runtime is completely - # isolated from any previous builds. - GRADLE_OPTS: "-Dorg.gradle.daemon=false" + # Let's see if setting this to true will improve speed any + GRADLE_OPTS: "-Dorg.gradle.daemon=true" # Pull core when building GIT_SUBMODULE_STRATEGY: recursive @@ -67,8 +65,16 @@ build_18-2: paths: - .gradle - cache/ + + +# should be done after the builds +# creates the archive zip containing all the built jars +archive: + stage: archive + script: + - echo 'Builds finished, creating archive.' # The compiler complains if we don't give it a "script" line artifacts: - # This should only be done for the last build, otherwise there will be a number of duplicate jars + # This should only be done for the last build, otherwise there will be duplicate jars name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" paths: # relative to the root directory From 5adfbb2dee7f7e44245b4ad0df68e1549f9f2fa5 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:04:50 +0000 Subject: [PATCH 26/48] Update .gitlab-ci.yml --- .gitlab-ci.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b95b3fdc1..6b19f0c60 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,6 @@ stages: - gradleSetup - build_18-1 - build_18-2 - - archive variables: # Let's see if setting this to true will improve speed any @@ -51,6 +50,13 @@ build_18-1: paths: - .gradle - cache/ + artifacts: + # This should only be done for the last build, otherwise there will be duplicate jars + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" + paths: + # relative to the root directory + - Merged + expire_in: 1 day # 1.18.2 build @@ -65,17 +71,9 @@ build_18-2: paths: - .gradle - cache/ - - -# should be done after the builds -# creates the archive zip containing all the built jars -archive: - stage: archive - script: - - echo 'Builds finished, creating archive.' # The compiler complains if we don't give it a "script" line artifacts: # This should only be done for the last build, otherwise there will be duplicate jars - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-2" paths: # relative to the root directory - Merged From 91712cee2adb77f54faf7c5eba41693a3d28cb12 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:21:44 +0000 Subject: [PATCH 27/48] Rough artifact test --- .gitlab-ci.yml | 55 +++++++++----------------------------------------- 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b19f0c60..57277495f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,12 +3,13 @@ image: gradle:eclipse-temurin # all stages need to be defined here stages: - - gradleSetup - - build_18-1 - - build_18-2 + #- gradleSetup + #- build_18-1 + #- build_18-2 + - artifacts variables: - # Let's see if setting this to true will improve speed any + # If we have correctness issues when compiling this can be set to false GRADLE_OPTS: "-Dorg.gradle.daemon=true" # Pull core when building GIT_SUBMODULE_STRATEGY: recursive @@ -22,55 +23,17 @@ before_script: -# This prevents us from re-downloading Gradle every stage -gradleSetup: - stage: gradleSetup - script: ./gradlew --build-cache --gradle-user-home cache/ check - # build using Java 17 - image: eclipse-temurin:17 - cache: - key: - files: - - gradle/wrapper/gradle-wrapper.properties - policy: push - paths: - - cache/ -# 1.18.1 build -build_18-1: - stage: build_18-1 - script: ./gradlew build -PmcVer=1.18.1 --gradle-user-home cache/; ./gradlew merge --gradle-user-home cache/ - # build using Java 17 - image: eclipse-temurin:17 - cache: - key: "$CI_COMMIT_REF_NAME_18-1" - policy: pull-push - paths: - - .gradle - - cache/ - artifacts: - # This should only be done for the last build, otherwise there will be duplicate jars - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" - paths: - # relative to the root directory - - Merged - expire_in: 1 day -# 1.18.2 build -build_18-2: +# put artifacts in a zip +artifacts: stage: build_18-2 - script: ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/; ./gradlew merge --gradle-user-home cache/ + script: echo 'Building complete. Creating artifact Zip.' # build using Java 17 image: eclipse-temurin:17 - cache: - key: "$CI_COMMIT_REF_NAME_18-2" - policy: pull-push - paths: - - .gradle - - cache/ artifacts: # This should only be done for the last build, otherwise there will be duplicate jars name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-2" @@ -81,7 +44,7 @@ build_18-2: -## - stage +# unused deployment stage #deploy: # stage: deploy # image: registry.gitlab.com/gitlab-org/release-cli:latest From b082b048d6054a60e9052eb5741094572a547cce Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:21:59 +0000 Subject: [PATCH 28/48] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 57277495f..03e0266f1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ before_script: # put artifacts in a zip artifacts: - stage: build_18-2 + stage: artifacts script: echo 'Building complete. Creating artifact Zip.' # build using Java 17 image: eclipse-temurin:17 From fe59c6b0c9eaaa66045cd16e6ab1f131c9dcd183 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:25:09 +0000 Subject: [PATCH 29/48] Check if Gradle setup is necessary --- .gitlab-ci.yml | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03e0266f1..ae334acad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,9 +3,9 @@ image: gradle:eclipse-temurin # all stages need to be defined here stages: - #- gradleSetup - #- build_18-1 - #- build_18-2 +# - gradleSetup + - build_18-1 + - build_18-2 - artifacts variables: @@ -21,22 +21,61 @@ before_script: - echo GE_JOB_ID=$CI_JOB_ID >> generate_jars.env +# # This prevents us from re-downloading Gradle every stage +# gradleSetup: +# stage: gradleSetup +# script: ./gradlew --build-cache --gradle-user-home cache/ check +# # build using Java 17 +# image: eclipse-temurin:17 +# cache: +# key: +# files: +# - gradle/wrapper/gradle-wrapper.properties +# policy: push +# paths: +# - cache/ +# 1.18.1 build +build_18-1: + stage: build_18-1 + script: ./gradlew build -PmcVer=1.18.1 --gradle-user-home cache/; ./gradlew merge --gradle-user-home cache/ + # build using Java 17 + image: eclipse-temurin:17 + cache: + key: "$CI_COMMIT_REF_NAME_18-1" + policy: pull-push + paths: + - .gradle + - cache/ +# 1.18.2 build +build_18-2: + stage: build_18-2 + script: ./gradlew build -PmcVer=1.18.2 --gradle-user-home cache/; ./gradlew merge --gradle-user-home cache/ + # build using Java 17 + image: eclipse-temurin:17 + cache: + key: "$CI_COMMIT_REF_NAME_18-2" + policy: pull-push + paths: + - .gradle + - cache/ # put artifacts in a zip +# This should only be done after all the builds have been completed artifacts: stage: artifacts + # The complier complains if we don't do something with the script line script: echo 'Building complete. Creating artifact Zip.' # build using Java 17 image: eclipse-temurin:17 artifacts: # This should only be done for the last build, otherwise there will be duplicate jars - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-2" + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" paths: # relative to the root directory - Merged From b9608498a2dab1ea50d1e8065623f579c5162f40 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:34:29 +0000 Subject: [PATCH 30/48] Check if Gradle setup is necessary + fix artifacts not being populated --- .gitlab-ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae334acad..b32add01b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ stages: # - gradleSetup - build_18-1 - build_18-2 - - artifacts +# - artifacts variables: # If we have correctness issues when compiling this can be set to false @@ -63,6 +63,13 @@ build_18-2: paths: - .gradle - cache/ + artifacts: + # This should only be done for the last build, otherwise there will be duplicate jars + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-2" + paths: + # relative to the root directory + - Merged + expire_in: 1 day # put artifacts in a zip From fae4bee87150a1abc2f418147be633a29f7e9b29 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:34:52 +0000 Subject: [PATCH 31/48] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b32add01b..88a2bba4e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,21 +72,21 @@ build_18-2: expire_in: 1 day -# put artifacts in a zip -# This should only be done after all the builds have been completed -artifacts: - stage: artifacts - # The complier complains if we don't do something with the script line - script: echo 'Building complete. Creating artifact Zip.' - # build using Java 17 - image: eclipse-temurin:17 - artifacts: - # This should only be done for the last build, otherwise there will be duplicate jars - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" - paths: - # relative to the root directory - - Merged - expire_in: 1 day +# # put artifacts in a zip +# # This should only be done after all the builds have been completed +# artifacts: +# stage: artifacts +# # The complier complains if we don't do something with the script line +# script: echo 'Building complete. Creating artifact Zip.' +# # build using Java 17 +# image: eclipse-temurin:17 +# artifacts: +# # This should only be done for the last build, otherwise there will be duplicate jars +# name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" +# paths: +# # relative to the root directory +# - Merged +# expire_in: 1 day From 8610917b865859f6c9f5b2be25ed81bee3b9a117 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:41:17 +0000 Subject: [PATCH 32/48] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88a2bba4e..7e0aa9263 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,6 +49,12 @@ build_18-1: paths: - .gradle - cache/ + artifacts: + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" + paths: + # relative to the root directory + - Merged + expire_in: 1 day # 1.18.2 build @@ -64,7 +70,6 @@ build_18-2: - .gradle - cache/ artifacts: - # This should only be done for the last build, otherwise there will be duplicate jars name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-2" paths: # relative to the root directory From c80b025ac187a1946cb6699f3bfa8fd8deee7096 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 03:52:25 +0000 Subject: [PATCH 33/48] Clean up the build script --- .gitlab-ci.yml | 55 ++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e0aa9263..c7b0b49ca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,10 +3,9 @@ image: gradle:eclipse-temurin # all stages need to be defined here stages: -# - gradleSetup - build_18-1 - build_18-2 -# - artifacts + - zip_artifacts variables: # If we have correctness issues when compiling this can be set to false @@ -21,22 +20,6 @@ before_script: - echo GE_JOB_ID=$CI_JOB_ID >> generate_jars.env -# # This prevents us from re-downloading Gradle every stage -# gradleSetup: -# stage: gradleSetup -# script: ./gradlew --build-cache --gradle-user-home cache/ check -# # build using Java 17 -# image: eclipse-temurin:17 -# cache: -# key: -# files: -# - gradle/wrapper/gradle-wrapper.properties -# policy: push -# paths: -# - cache/ - - - # 1.18.1 build build_18-1: stage: build_18-1 @@ -49,12 +32,6 @@ build_18-1: paths: - .gradle - cache/ - artifacts: - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-1" - paths: - # relative to the root directory - - Merged - expire_in: 1 day # 1.18.2 build @@ -69,31 +46,25 @@ build_18-2: paths: - .gradle - cache/ + + +# put artifacts in a zip +# This should only be done after all the builds have been completed +zip_artifacts: + stage: zip_artifacts + # The complier complains if we don't do something with the script line + script: echo 'Building complete. Creating artifact Zip.' + # build using Java 17 + image: eclipse-temurin:17 artifacts: - name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}_18-2" + # This should only be done after the last build, otherwise there will be duplicate jars + name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" paths: # relative to the root directory - Merged expire_in: 1 day -# # put artifacts in a zip -# # This should only be done after all the builds have been completed -# artifacts: -# stage: artifacts -# # The complier complains if we don't do something with the script line -# script: echo 'Building complete. Creating artifact Zip.' -# # build using Java 17 -# image: eclipse-temurin:17 -# artifacts: -# # This should only be done for the last build, otherwise there will be duplicate jars -# name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" -# paths: -# # relative to the root directory -# - Merged -# expire_in: 1 day - - # unused deployment stage #deploy: From 207cab9a0f00def0055434bdd01e8847b7a35fe4 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 15 Mar 2022 04:05:12 +0000 Subject: [PATCH 34/48] Clean up the build script --- .gitlab-ci.yml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7b0b49ca..b7a32635e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ image: gradle:eclipse-temurin stages: - build_18-1 - build_18-2 - - zip_artifacts +# - zip_artifacts variables: # If we have correctness issues when compiling this can be set to false @@ -46,16 +46,8 @@ build_18-2: paths: - .gradle - cache/ - - -# put artifacts in a zip -# This should only be done after all the builds have been completed -zip_artifacts: - stage: zip_artifacts - # The complier complains if we don't do something with the script line - script: echo 'Building complete. Creating artifact Zip.' - # build using Java 17 - image: eclipse-temurin:17 + + # TEMPORARY, there should be a way of either generating artifacts per build or in a separate stage artifacts: # This should only be done after the last build, otherwise there will be duplicate jars name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" @@ -65,6 +57,23 @@ zip_artifacts: expire_in: 1 day +# # put artifacts in a zip +# # This should only be done after all the builds have been completed +# zip_artifacts: +# stage: zip_artifacts +# # The complier complains if we don't do something with the script line +# script: echo 'Building complete. Creating artifact Zip.' +# # build using Java 17 +# image: eclipse-temurin:17 +# artifacts: +# # This should only be done after the last build, otherwise there will be duplicate jars +# name: "Merged_NightlyBuild-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}" +# paths: +# # relative to the root directory +# - Merged +# expire_in: 1 day + + # unused deployment stage #deploy: From 609ee5c70d01ab17891db175fd101a35176112b9 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Tue, 15 Mar 2022 12:37:51 +0800 Subject: [PATCH 35/48] Improve GLMessage Parser --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 1c0e7839c..323da0b12 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 1c0e7839c066ed96754de3f46186a240dd7fcc66 +Subproject commit 323da0b12c6faf08cf3a02698c0875a6d3242035 From 8259c79e9cf8897ab1555009bc027a7acca1c52f Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Tue, 15 Mar 2022 18:48:27 +1030 Subject: [PATCH 36/48] Fixup MixinUtilBackgroudThread+more render log --- core | 2 +- .../main/java/com/seibel/lod/fabric/ClientProxy.java | 6 ++++++ .../lod/fabric/mixins/MixinUtilBackgroudThread.java | 10 ++++------ .../seibel/lod/fabric/mixins/MixinWorldRenderer.java | 5 ++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/core b/core index 323da0b12..e8de59a22 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 323da0b12c6faf08cf3a02698c0875a6d3242035 +Subproject commit e8de59a226d6d3eb0a062dfb4a86e2a682a6e9c0 diff --git a/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java b/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java index c238f165d..ef7c35924 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java @@ -19,6 +19,7 @@ package com.seibel.lod.fabric; +import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.api.EventApi; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; @@ -29,6 +30,7 @@ import com.seibel.lod.common.wrappers.world.WorldWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; +import com.seibel.lod.fabric.mixins.MixinUtilBackgroudThread; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; @@ -43,6 +45,7 @@ import net.minecraft.world.level.chunk.LevelChunk; import java.util.HashSet; import java.util.List; +import java.util.function.Supplier; import org.lwjgl.glfw.GLFW; @@ -59,6 +62,7 @@ public class ClientProxy private final EventApi eventApi = EventApi.INSTANCE; private final ClientApi clientApi = ClientApi.INSTANCE; + public static Supplier isGenerationThreadChecker = null; /** * Registers Fabric Events @@ -88,6 +92,8 @@ public class ClientProxy ClientTickEvents.END_CLIENT_TICK.register(client -> { if (client.player != null) onKeyInput(); }); + isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread; + } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java index e2a1536e1..327aaadca 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java @@ -3,14 +3,12 @@ package com.seibel.lod.fabric.mixins; import java.util.concurrent.ExecutorService; import java.util.function.Supplier; +import com.seibel.lod.fabric.ClientProxy; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import com.seibel.lod.common.wrappers.DependencySetupDoneCheck; -import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; -import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.util.DummyRunExecutorService; import net.minecraft.Util; @@ -23,7 +21,7 @@ public class MixinUtilBackgroudThread at = @At("HEAD"), cancellable = true) private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable ci) { - if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread()) + if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get()) { //ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered"); ci.setReturnValue(r); @@ -33,7 +31,7 @@ public class MixinUtilBackgroudThread at = @At("HEAD"), cancellable = true) private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier r, CallbackInfoReturnable> ci) { - if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread()) + if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get()) { //ApiShared.LOGGER.info("util wrapThreadWithTaskName(Supplier) triggered"); ci.setReturnValue(r); @@ -43,7 +41,7 @@ public class MixinUtilBackgroudThread @Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true) private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable ci) { - if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread()) + if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get()) { //ApiShared.LOGGER.info("util backgroundExecutor triggered"); ci.setReturnValue(new DummyRunExecutorService()); diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java index 9264da68f..cc42691cc 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java @@ -61,7 +61,9 @@ public class MixinWorldRenderer } // HEAD or RETURN - @Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V") + @Inject(at = @At("HEAD"), + method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V", + cancellable = true) private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback) { // only render before solid blocks @@ -72,5 +74,6 @@ public class MixinWorldRenderer ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks); } + //callback.cancel(); } } From 56f940385920ebd0cf265de2813b47c7c1456926 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Tue, 15 Mar 2022 16:38:39 +0800 Subject: [PATCH 37/48] Add proper multi FrameBuffer support(And fix MacOS?) --- .../common/wrappers/minecraft/MinecraftRenderWrapper.java | 5 +++++ core | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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 34612ce19..c533cc720 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 @@ -143,6 +143,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper return MC.getWindow().getHeight(); } + @Override + public int getTargetFrameBuffer() { + return MC.getMainRenderTarget().frameBufferId; + } + /** * This method returns the ChunkPos of all chunks that Minecraft * is going to render this frame.

diff --git a/core b/core index e8de59a22..4f563c2be 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit e8de59a226d6d3eb0a062dfb4a86e2a682a6e9c0 +Subproject commit 4f563c2be5b50c2717a61a4b59045b6ca5d6eb5b From 3e87e625baabaa546b3dc8aaa868986149badd46 Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Tue, 15 Mar 2022 21:17:07 +1030 Subject: [PATCH 38/48] Pushed the stuff leetom did on my macbook --- .../minecraft/MinecraftRenderWrapper.java | 18 +++++++++++++++++- core | 2 +- .../lod/fabric/mixins/MixinWorldRenderer.java | 17 ++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) 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 c533cc720..00b3b9dd5 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 @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.stream.Collectors; +import com.mojang.blaze3d.pipeline.RenderTarget; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; import com.seibel.lod.common.wrappers.misc.LightMapWrapper; @@ -143,9 +144,24 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper return MC.getWindow().getHeight(); } + private RenderTarget getRenderTarget() { + RenderTarget r = null; //MC.levelRenderer.getCloudsTarget(); + return r!=null ? r : MC.getMainRenderTarget(); + } + @Override public int getTargetFrameBuffer() { - return MC.getMainRenderTarget().frameBufferId; + return getRenderTarget().frameBufferId; + } + + @Override + public int getTargetFrameBufferViewportWidth() { + return getRenderTarget().viewWidth; + } + + @Override + public int getTargetFrameBufferViewportHeight() { + return getRenderTarget().viewHeight; } /** diff --git a/core b/core index 4f563c2be..cf519c02b 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 4f563c2be5b50c2717a61a4b59045b6ca5d6eb5b +Subproject commit cf519c02be2c7067bb0f52fd62164a503b3a884a diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java index cc42691cc..cc656e644 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java @@ -60,6 +60,21 @@ public class MixinWorldRenderer previousPartialTicks = tickDelta; } + // HEAD or RETURN + @Inject(at = @At("RETURN"), + method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/math/Matrix4f;FLjava/lang/Runnable;)V", + cancellable = true) + private void renderLod(PoseStack modelViewMatrixStack, Matrix4f projectionMatrix, float f, Runnable r, CallbackInfo callback) { + + Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose()); + Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix); + + ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks); + + } + + /* + // HEAD or RETURN @Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V", @@ -75,5 +90,5 @@ public class MixinWorldRenderer ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks); } //callback.cancel(); - } + }*/ } From c0d5dd6deea54fc0b0d8b10dbf268f93fe06e67e Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Wed, 16 Mar 2022 18:50:42 +0800 Subject: [PATCH 39/48] ADVANCED FOGGGGGGGGGGGGGGGG~~~~~~~~~~~~~~~~ --- .../java/com/seibel/lod/common/Config.java | 20 ++++++--- .../config/LodConfigWrapperSingleton.java | 42 +++++++++++++------ 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index e3f0e8306..f97d45dda 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -185,7 +185,7 @@ public class Config @ConfigAnnotations.FileComment public static String _farFogType = IAdvancedFog.FAR_FOG_TYPE_DESC; @ConfigAnnotations.Entry - public static FogSetting.Type farFogType = IAdvancedFog.FAR_FOG_TYPE_DEFAULT; + public static FogSetting.FogType farFogType = IAdvancedFog.FAR_FOG_TYPE_DEFAULT; @ConfigAnnotations.FileComment public static String _farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_DESC; @@ -193,15 +193,24 @@ public class Config public static double farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; @ConfigAnnotations.ScreenEntry - public static HeightFog HeightFog; + public static HeightFog heightFog; public static class HeightFog { @ConfigAnnotations.FileComment - public static String _heightFogTMode = IHeightFog.HEIGHT_FOG_MODE_DESC; + public static String _heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DESC; + @ConfigAnnotations.Entry + public static HeightFogMixMode heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DEFAULT; + @ConfigAnnotations.FileComment + public static String _heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DESC; @ConfigAnnotations.Entry public static HeightFogMode heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DEFAULT; + @ConfigAnnotations.FileComment + public static String _heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_DESC; + @ConfigAnnotations.Entry(minValue = -4096.0, maxValue = 4096.0) + public static double heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_MIN_DEFAULT_MAX.defaultValue; + @ConfigAnnotations.FileComment public static String _heightFogStart = IHeightFog.HEIGHT_FOG_START_DESC; @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) @@ -225,13 +234,14 @@ public class Config @ConfigAnnotations.FileComment public static String _heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DESC; @ConfigAnnotations.Entry - public static FogSetting.Type heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DEFAULT; + public static FogSetting.FogType heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DEFAULT; @ConfigAnnotations.FileComment public static String _heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_DESC; @ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0) public static double heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; - } + + } } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 57299f134..d1ff86816 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -299,7 +299,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax; } @Override - public FogSetting.Type getFarFogType() { + public FogSetting.FogType getFarFogType() { return Config.Client.Graphics.FogQuality.AdvancedFog.farFogType; } @Override @@ -328,7 +328,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMax"); } @Override - public void setFarFogType(FogSetting.Type newFarFogType) { + public void setFarFogType(FogSetting.FogType newFarFogType) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogType").value = newFarFogType; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogType"); } @@ -345,41 +345,59 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton public static class HeightFog implements IHeightFog { + @Override + public HeightFogMixMode getHeightFogMixMode() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMixMode; + } @Override public HeightFogMode getHeightFogMode() { - return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMode; + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMode; + } + @Override + public double getHeightFogHeight() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogHeight; } @Override public double getHeightFogStart() { - return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogStart; + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogStart; } @Override public double getHeightFogEnd() { - return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogEnd; + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogEnd; } @Override public double getHeightFogMin() { - return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMin; + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMin; } @Override public double getHeightFogMax() { - return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogMax; + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMax; } @Override - public FogSetting.Type getHeightFogType() { - return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogType; + public FogSetting.FogType getHeightFogType() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogType; } @Override public double getHeightFogDensity() { - return Config.Client.Graphics.FogQuality.AdvancedFog.HeightFog.heightFogDensity; + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogDensity; } @Override - public void setHeightFogType(HeightFogMode newHeightFogMode) { + public void setHeightFogMixMode(HeightFogMixMode newHeightFogMixMode) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode").value = newHeightFogMixMode; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode"); + } + @Override + public void setHeightFogMode(HeightFogMode newHeightFogMode) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode").value = newHeightFogMode; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode"); } @Override + public void setHeightFogHeight(double newHeightFogHeight) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight").value = newHeightFogHeight; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight"); + } + @Override public void setHeightFogStart(double newHeightFogStart) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart").value = newHeightFogStart; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart"); @@ -400,7 +418,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax"); } @Override - public void setHeightFogType(FogSetting.Type newHeightFogType) { + public void setHeightFogType(FogSetting.FogType newHeightFogType) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogType").value = newHeightFogType; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogType"); } From 780d0ad9fbc921b366df7a48d6a75a414269d800 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Wed, 16 Mar 2022 18:52:37 +0800 Subject: [PATCH 40/48] Complete the push --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index cf519c02b..2907c8e3e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit cf519c02be2c7067bb0f52fd62164a503b3a884a +Subproject commit 2907c8e3e7bbbe570328057b41c2baf116ddec37 From 35bef76aeb5ec8b6db1ec9d6c4f3ee27c8d5c4b0 Mon Sep 17 00:00:00 2001 From: TomTheFurry <46843632+TomTheFurry@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:57:27 +0800 Subject: [PATCH 41/48] Fix 1.18.2 WorldRenderer renderSky() mixin falling --- build.properties | 2 +- .../com/seibel/lod/fabric/mixins/MixinWorldRenderer.java | 6 ++++-- gradle.properties | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.properties b/build.properties index f059b81db..ae4f3e14a 100644 --- a/build.properties +++ b/build.properties @@ -1 +1 @@ -MC_VERSION_1_18_1= +MC_VERSION_1_18_2= diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java index cc656e644..5af847ea4 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java @@ -24,6 +24,7 @@ import com.mojang.math.Matrix4f; import com.seibel.lod.common.wrappers.McObjectConverter; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.objects.math.Mat4f; +import net.minecraft.client.Camera; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.RenderType; import org.spongepowered.asm.mixin.Mixin; @@ -62,9 +63,10 @@ public class MixinWorldRenderer // HEAD or RETURN @Inject(at = @At("RETURN"), - method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/math/Matrix4f;FLjava/lang/Runnable;)V", + method = "renderSky", cancellable = true) - private void renderLod(PoseStack modelViewMatrixStack, Matrix4f projectionMatrix, float f, Runnable r, CallbackInfo callback) { + private void renderLod(PoseStack modelViewMatrixStack, Matrix4f projectionMatrix, float f, + #if MC_VERSION_1_18_2 Camera camera, boolean bl,#endif Runnable r, CallbackInfo callback) { Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose()); Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix); diff --git a/gradle.properties b/gradle.properties index 736b8a929..8ddcaa853 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,4 @@ toml_version=3.6.4 manifold_version=2022.1.5 ##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: -mcVer=1.18.1 \ No newline at end of file +mcVer=1.18.2 \ No newline at end of file From 7a91b258dec2b7b9e96230456f12e675366cbd2b Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Thu, 17 Mar 2022 17:52:19 +1030 Subject: [PATCH 42/48] Updated mods, readme and fixed 1 thing in the config gui --- 1.18.1.properties | 6 +++--- 1.18.2.properties | 14 ++++++------- Readme.md | 21 ++++++++++++++----- .../lod/common/wrappers/config/ConfigGui.java | 1 + 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/1.18.1.properties b/1.18.1.properties index 3fae30657..5fd17ffb0 100644 --- a/1.18.1.properties +++ b/1.18.1.properties @@ -4,8 +4,8 @@ minecraft_version=1.18.1 java_version = 17 # Fabric loader -fabric_loader_version=0.13.2 -fabric_api_version=0.46.4+1.18 +fabric_loader_version=0.13.3 +fabric_api_version=0.46.6+1.18 # Fabric mod versions modmenu_version=3.0.1 starlight_version_fabric=3554912 @@ -26,7 +26,7 @@ fabric_api_version=0.46.4+1.18 enable_bclib=0 # Forge loader -forge_version=39.0.76 +forge_version=39.1.2 # Forge mod versions starlight_version_forge=3559934 diff --git a/1.18.2.properties b/1.18.2.properties index 646007ceb..daf7e8ff3 100644 --- a/1.18.2.properties +++ b/1.18.2.properties @@ -6,15 +6,15 @@ java_version = 17 # Fabric loader fabric_loader_version=0.13.3 -fabric_api_version=0.47.8+1.18.2 +fabric_api_version=0.48.0+1.18.2 # Fabric mod versions modmenu_version=3.1.0 - starlight_version_fabric=3554912 - lithium_version=mc1.18.1-0.7.7 + starlight_version_fabric=3667443 + lithium_version=mc1.18.2-0.7.9 sodium_version=3669187 - iris_version=1.18.x-v1.1.4 - bclib_version=1.2.5 + iris_version=1.18.x-v1.2.2 immersive_portals_version = v1.0.4-1.18 + bclib_version=0 # Fabric mod run # 0 = Don't enable and don't run @@ -27,9 +27,9 @@ fabric_api_version=0.47.8+1.18.2 enable_bclib=0 # Forge loader -forge_version=40.0.1 +forge_version=40.0.18 # Forge mod versions - starlight_version_forge=3559934 + starlight_version_forge=0 # Forge mod run # 0 = Dont enable and don't run diff --git a/Readme.md b/Readme.md index 801747962..2bf0d9f2e 100644 --- a/Readme.md +++ b/Readme.md @@ -14,13 +14,24 @@ If you want to see a quick demo, check out a video covering the mod here: ![Minecraft Level Of Detail (LOD) mod - Alpha 1.5](https://i.ytimg.com/vi_webp/H2tnvEVbO1c/mqdefault.webp) +### Versions + Architectury version: 3.4-SNAPSHOT\ -Forge version: 39.0.5 and 38.0.14\ -Fabric version: 0.13.2\ -Fabric API version: 0.44.0+1.18\ -Modmenu version: 3.0.1\ Java Compiler plugin: Manifold Preprocessor +#### 1.18.2 mods +Forge version: 40.0.18\ +Fabric version: 0.13.3\ +Fabric API version: 0.48.0+1.18.2\ +Modmenu version: 3.1.0 + +#### 1.18.1 mods +Forge version: 39.1.2\ +Fabric version: 0.13.3\ +Fabric API version: 0.46.6+1.18\ +Modmenu version: 3.0.1 + + Notes:\ This version has been confirmed to work in IDE and Retail Minecraft.\ (Retail running forge version 1.18.1-39.0.5 and fabric version 1.18-0.12.12 and 1.18.1-0.13.2) @@ -69,7 +80,7 @@ If running on IDE, to ensure IDE pickup the changed versions, you will need to r 6. The compiled jar file will be in the folder `Merged` **If in terminal:** -1. `git clone -b 1.18.X --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git` +1. `git clone -b preprocessor_test --recurse-submodules https://gitlab.com/jeseibel/minecraft-lod-mod.git` 2. `cd minecraft-lod-mod` 3. `./gradlew assemble` 4. `./gradlew mergeJars` 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 7f099fcff..ff230ac63 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 @@ -607,6 +607,7 @@ public abstract class ConfigGui else if (info.screenButton) { Button widget = new Button(this.width / 2 - info.width, this.height - 28, info.width * 2, 20, name, (button -> { + saveToFile(); Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, info.gotoScreen)); })); this.list.addButton(widget, null, null, null); From b6a893085583e75da860950af22e57e23e7c498b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 18 Mar 2022 23:57:32 -0500 Subject: [PATCH 43/48] Add a config for the MultiDimension Similarity --- .../java/com/seibel/lod/common/Config.java | 9 ++++++++- .../config/LodConfigWrapperSingleton.java | 18 +++++++++++++++--- core | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index 03b862f27..b92a9c324 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -223,11 +223,18 @@ public class Config } - public static class Multiplayer { + public static class Multiplayer + { @ConfigAnnotations.FileComment public static String _serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DESC; @ConfigAnnotations.Entry public static ServerFolderNameMode serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DESC; + @ConfigAnnotations.Entry + public static double multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DEFAULT; + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index e14915705..756c11a9b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -3,7 +3,6 @@ package com.seibel.lod.common.wrappers.config; import com.seibel.lod.core.enums.config.*; import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; -import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.common.Config; /** @@ -432,8 +431,21 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.multiplayer.serverFolderNameMode").value = newServerFolderNameMode; ConfigGui.editSingleOption.saveOption("client.multiplayer.serverFolderNameMode"); } - - + + @Override + public double getMultiDimensionRequiredSimilarity() + { + return Config.Client.Multiplayer.multiDimensionRequiredSimilarity; + } + + @Override + public void setMultiDimensionRequiredSimilarity(double newMultiDimensionMinimumSimilarityPercent) + { + ConfigGui.editSingleOption.getEntry("client.multiplayer.multiDimensionMinimumSimilarityPercent").value = newMultiDimensionMinimumSimilarityPercent; + ConfigGui.editSingleOption.saveOption("client.multiplayer.multiDimensionMinimumSimilarityPercent"); + } + + } diff --git a/core b/core index bca2b6180..9fa7fa843 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit bca2b61800b613b630def131e9c9f85f9736493d +Subproject commit 9fa7fa843d442f199e74cb5c38cc2ef227c53950 From 6f929f40f937d8cf8dd8922c2234a6c7757f62df Mon Sep 17 00:00:00 2001 From: tom lee Date: Sat, 19 Mar 2022 22:34:11 +0800 Subject: [PATCH 44/48] Update core --- .../lod/common/wrappers/VersionConstants.java | 16 +- .../lod/common/wrappers/WrapperFactory.java | 10 -- .../minecraft/MinecraftRenderWrapper.java | 2 +- .../BatchGenerationEnvironment.java | 72 ++++----- .../WorldGeneratorWrapper.java | 153 ------------------ .../worldGeneration/step/StepFeatures.java | 4 +- .../worldGeneration/step/StepLight.java | 4 +- core | 2 +- 8 files changed, 38 insertions(+), 225 deletions(-) delete mode 100644 common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java b/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java index 837cd6ccd..e516efab0 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java @@ -24,26 +24,12 @@ public class VersionConstants implements IVersionConstants { return 0; } - - @Override - public boolean isWorldGeneratorSingleThreaded(DistanceGenerationMode distanceGenerationMode) - { - return true; - } - + @Override public int getWorldGenerationCountPerThread() { return 1; } - - - @Override - public boolean hasBatchGenerationImplementation() - { - return true; - } - @Override public boolean isVanillaRenderedChunkSquare() diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java index 77b145c6e..d6839eb71 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/WrapperFactory.java @@ -26,11 +26,9 @@ import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper; import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper; -import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractWorldGeneratorWrapper; import com.seibel.lod.common.wrappers.block.BlockPosWrapper; import com.seibel.lod.common.wrappers.chunk.ChunkPosWrapper; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; -import com.seibel.lod.common.wrappers.worldGeneration.WorldGeneratorWrapper; /** * This handles creating abstract wrapper objects. @@ -88,14 +86,6 @@ public class WrapperFactory implements IWrapperFactory return new ChunkPosWrapper(blockPos); } - - - @Override - public AbstractWorldGeneratorWrapper createWorldGenerator(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper) - { - return new WorldGeneratorWrapper(newLodBuilder, newLodDimension, worldWrapper); - } - public AbstractBatchGenerationEnvionmentWrapper createBatchGenerator(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper) { 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 00b3b9dd5..c136c7f86 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 @@ -208,7 +208,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper MinecraftClientWrapper.INSTANCE.sendChatMessage( "\u00A7eOverdraw prevention will be worse than normal."); } catch (Exception e2) {} - ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e); + ApiShared.LOGGER.error("getVanillaRenderedChunks Error: ", e); usingBackupGetVanillaRenderedChunks = true; } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 142c859cf..5945ddee4 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -20,14 +20,13 @@ package com.seibel.lod.common.wrappers.worldGeneration; import com.seibel.lod.core.api.ApiShared; -import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.builders.lodBuilding.LodBuilder; import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig; import com.seibel.lod.core.enums.config.DistanceGenerationMode; import com.seibel.lod.core.enums.config.LightGenerationMode; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.objects.lod.LodDimension; -import com.seibel.lod.core.util.GridList; +import com.seibel.lod.core.util.gridList.ArrayGridList; import com.seibel.lod.core.util.LodThreadFactory; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; @@ -191,7 +190,6 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (e.endNano != 0) { lodTime.add(e.endNano - preTime); - preTime = e.endNano; } } @@ -215,7 +213,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv //=================Generation Step=================== - public final LinkedList events = new LinkedList(); + public final LinkedList events = new LinkedList<>(); public final GlobalParameters params; public final StepStructureStart stepStructureStart = new StepStructureStart(this); public final StepStructureReference stepStructureReference = new StepStructureReference(this); @@ -230,12 +228,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv private static final IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class); public static final long EXCEPTION_TIMER_RESET_TIME = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); public static final int EXCEPTION_COUNTER_TRIGGER = 20; + public static final int RANGE_TO_RANGE_EMPTY_EXTENSION = 1; public int unknownExceptionCount = 0; public long lastExceptionTriggerTime = 0; public static final LodThreadFactory threadFactory = new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY); - public static ThreadLocal isDistantGeneratorThread = new ThreadLocal(); + public static ThreadLocal isDistantGeneratorThread = new ThreadLocal<>(); public static boolean isCurrentThreadDistantGeneratorThread() { return (isDistantGeneratorThread.get() != null); @@ -384,22 +383,20 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (ENABLE_EVENT_LOGGING) ApiShared.LOGGER.info("Lod Generate Event: " + e.pos); e.pEvent.beginNano = System.nanoTime(); - GridList referencedChunks; + ArrayGridList referencedChunks; + ArrayGridList genChunks; DistanceGenerationMode generationMode; LightedWorldGenRegion region; WorldGenLevelLightEngine lightEngine; LightGetterAdaptor adaptor; - + int refRange = e.range + RANGE_TO_RANGE_EMPTY_EXTENSION; + int refOffsetX = e.pos.x - refRange; + int refOffsetZ = e.pos.z - refRange; try { adaptor = new LightGetterAdaptor(params.level); lightEngine = new WorldGenLevelLightEngine(adaptor); - - int cx = e.pos.x; - int cy = e.pos.z; - int rangeEmpty = e.range + 1; - GridList chunks = new GridList(rangeEmpty); - + @SuppressWarnings("resource") EmptyChunkGenerator generator = (int x, int z) -> { @@ -418,23 +415,19 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv params.biomes, null); return target; }; - - for (int oy = -rangeEmpty; oy <= rangeEmpty; oy++) - { - for (int ox = -rangeEmpty; ox <= rangeEmpty; ox++) - { - ChunkAccess target = generator.generate(cx + ox, cy + oy); - chunks.add(target); - } - } + + referencedChunks = new ArrayGridList<>(refRange*2+1, + (x,z) -> generator.generate(x + refOffsetX,z + refOffsetZ) + ); e.pEvent.emptyNano = System.nanoTime(); e.refreshTimeout(); - region = new LightedWorldGenRegion(params.level, lightEngine, chunks, ChunkStatus.STRUCTURE_STARTS, rangeEmpty, e.lightMode, generator); + region = new LightedWorldGenRegion(params.level, lightEngine, referencedChunks, + ChunkStatus.STRUCTURE_STARTS, refRange, e.lightMode, generator); adaptor.setRegion(region); e.tParam.makeStructFeat(region); - referencedChunks = chunks.subGrid(e.range); - referencedChunks = generateDirect(e, referencedChunks, e.target, region); - + genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION, + referencedChunks.gridSize - RANGE_TO_RANGE_EMPTY_EXTENSION); + generateDirect(e, genChunks, e.target, region); } catch (StepStructureStart.StructStartCorruptedException f) { @@ -466,14 +459,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv default: return; } - int centreIndex = referencedChunks.size() / 2; - for (int oy = -e.range; oy <= e.range; oy++) + for (int oy = 0; oy < genChunks.gridSize; oy++) { - for (int ox = -e.range; ox <= e.range; ox++) + for (int ox = 0; ox < genChunks.gridSize; ox++) { - int targetIndex = referencedChunks.offsetOf(centreIndex, ox, oy); - ChunkAccess target = referencedChunks.get(targetIndex); + ChunkAccess target = genChunks.get(ox, oy); ChunkWrapper wrappedChunk = new ChunkWrapper(target, region); if (!wrappedChunk.isLightCorrect()) { throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false"); @@ -521,8 +512,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } } - public GridList generateDirect(GenerationEvent e, GridList subRange, Steps step, - LightedWorldGenRegion region) + public void generateDirect(GenerationEvent e, ArrayGridList subRange, Steps step, + LightedWorldGenRegion region) { try { @@ -535,38 +526,37 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } }); if (step == Steps.Empty) - return subRange; + return; stepStructureStart.generateGroup(e.tParam, region, subRange); e.pEvent.structStartNano = System.nanoTime(); e.refreshTimeout(); if (step == Steps.StructureStart) - return subRange; + return; stepStructureReference.generateGroup(e.tParam, region, subRange); e.pEvent.structRefNano = System.nanoTime(); e.refreshTimeout(); if (step == Steps.StructureReference) - return subRange; + return; stepBiomes.generateGroup(e.tParam, region, subRange); e.pEvent.biomeNano = System.nanoTime(); e.refreshTimeout(); if (step == Steps.Biomes) - return subRange; + return; stepNoise.generateGroup(e.tParam, region, subRange); e.pEvent.noiseNano = System.nanoTime(); e.refreshTimeout(); if (step == Steps.Noise) - return subRange; + return; stepSurface.generateGroup(e.tParam, region, subRange); e.pEvent.surfaceNano = System.nanoTime(); e.refreshTimeout(); if (step == Steps.Surface) - return subRange; + return; if (step == Steps.Carvers) - return subRange; + return; stepFeatures.generateGroup(e.tParam, region, subRange); e.pEvent.featureNano = System.nanoTime(); e.refreshTimeout(); - return subRange; } finally { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java deleted file mode 100644 index 599af6dcf..000000000 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java +++ /dev/null @@ -1,153 +0,0 @@ - -package com.seibel.lod.common.wrappers.worldGeneration; - -import com.seibel.lod.core.builders.lodBuilding.LodBuilder; -import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig; -import com.seibel.lod.core.enums.config.DistanceGenerationMode; -import com.seibel.lod.core.objects.lod.LodDimension; -import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; -import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper; -import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractWorldGeneratorWrapper; - -import com.seibel.lod.common.wrappers.chunk.ChunkWrapper; -import com.seibel.lod.common.wrappers.world.WorldWrapper; - -import net.minecraft.world.level.chunk.*; -/* */ -/* */ import net.minecraft.server.level.ServerLevel; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ - -/** - * @author James Seibel - * @version 11-13-2021 - */ -public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper -{ - public final ServerLevel serverWorld; - public final LodDimension lodDim; - public final LodBuilder lodBuilder; - - public WorldGeneratorWrapper(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper) - { - super(newLodBuilder, newLodDimension, worldWrapper); - - lodBuilder = newLodBuilder; - lodDim = newLodDimension; - serverWorld = ((WorldWrapper) worldWrapper).getServerWorld(); - } - - /** takes about 2-5 ms */ - @Override - public void generateBiomesOnly(AbstractChunkPosWrapper pos, DistanceGenerationMode generationMode) - { - generate(pos.getX(), pos.getZ(), generationMode); - } - - /** takes about 10 - 20 ms */ - @Override - public void generateSurface(AbstractChunkPosWrapper pos) - { - generate(pos.getX(), pos.getZ(), DistanceGenerationMode.SURFACE); - } - - /** - * takes about 15 - 20 ms - */ - @Override - public void generateFeatures(AbstractChunkPosWrapper pos) - { - generate(pos.getX(), pos.getZ(), DistanceGenerationMode.FEATURES); - } - - /** - * Generates using MC's ServerWorld. - *

- * on pre generated chunks 0 - 1 ms
- * on un generated chunks 0 - 50 ms
- * with the median seeming to hover around 15 - 30 ms
- * and outliers in the 100 - 200 ms range
- *

- * Note this should not be multithreaded and does cause server/simulation lag - * (Higher lag for generating than loading) - */ - @Override - public void generateFull(AbstractChunkPosWrapper pos) - { - generate(pos.getX(), pos.getZ(), DistanceGenerationMode.FULL); - } - - private void generate(int chunkX, int chunkZ, DistanceGenerationMode generationMode) - { - - // long t = System.nanoTime(); - - ChunkStatus targetStatus; - switch (generationMode) - { - case BIOME_ONLY: - targetStatus = ChunkStatus.BIOMES; - break; - case BIOME_ONLY_SIMULATE_HEIGHT: - targetStatus = ChunkStatus.NOISE; - break; - case SURFACE: - targetStatus = ChunkStatus.SURFACE; - break; - case FEATURES: - targetStatus = ChunkStatus.FEATURES; - break; - case FULL: - targetStatus = ChunkStatus.FULL; - break; - case NONE: - default: - return; - } - - // The bool=true means that we wants to generate chunk, and that the returned ChunkAccess must not be null - ChunkAccess ca = serverWorld.getChunkSource().getChunk(chunkX, chunkZ, targetStatus, true); - if (ca == null) - throw new RuntimeException("This should NEVER be null due to bool being true"); - lodBuilder.generateLodNodeFromChunk(lodDim, new ChunkWrapper(ca, serverWorld), new LodBuilderConfig(generationMode), false, true); - - // long duration = System.nanoTime()-t; - - // Debug print the duration - // System.out.println("LodChunkGenFull["+chunkX+","+chunkZ+"]: "+(double)(duration)/1000.); - - } - - /* TODO: Update this chart - * performance/generation tests related to - * serverWorld.getChunk(x, z, ChunkStatus. *** ) - - true/false is whether they generated blocks or not - the time is how long it took to generate - - ChunkStatus.EMPTY 0 - 1 ms false (empty, what did you expect? :P) - ChunkStatus.STRUCTURE_REFERENCES 1 - 2 ms false (no height, only generates some chunks) - ChunkStatus.BIOMES 1 - 10 ms false (no height) - ChunkStatus.NOISE 4 - 15 ms true (all blocks are stone) - ChunkStatus.LIQUID_CARVERS 6 - 12 ms true (no snow/trees, just grass) - ChunkStatus.SURFACE 5 - 15 ms true (no snow/trees, just grass) - ChunkStatus.CARVERS 5 - 30 ms true (no snow/trees, just grass) - ChunkStatus.FEATURES 7 - 25 ms true - ChunkStatus.HEIGHTMAPS 20 - 40 ms true - ChunkStatus.LIGHT 20 - 40 ms true - ChunkStatus.FULL 30 - 50 ms true - ChunkStatus.SPAWN 50 - 80 ms true - - At this point I would suggest using FEATURES, as it generates snow and trees - (and any other object that are needed to make biomes distinct) - - Otherwise, if snow/trees aren't necessary SURFACE is the next fastest (although not by much) - */ -} \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java index ee14b5ee5..a17fa172e 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters; -import com.seibel.lod.core.util.GridList; +import com.seibel.lod.core.util.gridList.ArrayGridList; import net.minecraft.ReportedException; import net.minecraft.server.level.WorldGenRegion; @@ -30,7 +30,7 @@ public final class StepFeatures { public final ChunkStatus STATUS = ChunkStatus.FEATURES; public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, - GridList chunks) { + ArrayGridList chunks) { ArrayList chunksToDo = new ArrayList(); for (ChunkAccess chunk : chunks) { diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java index b2d1a84bd..90ef6ef5b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java @@ -2,7 +2,7 @@ package com.seibel.lod.common.wrappers.worldGeneration.step; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenLevelLightEngine; -import com.seibel.lod.core.util.GridList; +import com.seibel.lod.core.util.gridList.ArrayGridList; import net.minecraft.server.level.ThreadedLevelLightEngine; import net.minecraft.world.level.chunk.ChunkAccess; @@ -28,7 +28,7 @@ public final class StepLight { public final ChunkStatus STATUS = ChunkStatus.LIGHT; public void generateGroup(LightEventListener lightEngine, - GridList chunks) { + ArrayGridList chunks) { //ArrayList chunksToDo = new ArrayList(); for (ChunkAccess chunk : chunks) { diff --git a/core b/core index 2907c8e3e..804738cfe 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 2907c8e3e7bbbe570328057b41c2baf116ddec37 +Subproject commit 804738cfe5eb7ce4312bf6cd84e559bb3f6127db From 6c7e1900a3f55941351b0b42316e6e84c265bbe3 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 19 Mar 2022 11:20:44 -0500 Subject: [PATCH 45/48] Merge in fog changes --- .../java/com/seibel/lod/common/Config.java | 193 ++++++-- .../common/wrappers/chunk/ChunkWrapper.java | 251 +++++----- .../config/LodConfigWrapperSingleton.java | 349 ++++++++++---- .../minecraft/MinecraftRenderWrapper.java | 438 +++++++++--------- .../common/wrappers/world/WorldWrapper.java | 66 +-- core | 2 +- 6 files changed, 810 insertions(+), 489 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index b92a9c324..d53063855 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -25,14 +25,18 @@ import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.*; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.IAdvancedFog.IHeightFog; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator; + /** * This handles any configuration the user has access to. * @author coolGi2007 * @version 12-12-2021 */ + public class Config //public class Config extends TinyConfig { @@ -50,12 +54,12 @@ public class Config // |-> Threads // |-> Buffers // |-> Debugging - + // Since the original config system uses forge stuff, that means we have to rewrite the whole config system - + @ConfigAnnotations.ScreenEntry public static Client client; - + @ConfigAnnotations.FileComment public static String _optionsButton = ILodConfigWrapperSingleton.IClient.OPTIONS_BUTTON_DESC; // I know this option should be in Client @@ -63,91 +67,184 @@ public class Config // Tough it is in client in the wrapper singleton @ConfigAnnotations.Entry public static boolean optionsButton = true; - + public static class Client { @ConfigAnnotations.ScreenEntry public static Graphics graphics; - + @ConfigAnnotations.ScreenEntry public static WorldGenerator worldGenerator; - + @ConfigAnnotations.ScreenEntry public static Multiplayer multiplayer; - + @ConfigAnnotations.ScreenEntry public static Advanced advanced; - - + + public static class Graphics { @ConfigAnnotations.ScreenEntry public static Quality quality; - + @ConfigAnnotations.ScreenEntry public static FogQuality fogQuality; - + @ConfigAnnotations.ScreenEntry public static AdvancedGraphics advancedGraphics; - - + + public static class Quality { @ConfigAnnotations.FileComment public static String _drawResolution = IQuality.DRAW_RESOLUTION_DESC; @ConfigAnnotations.Entry public static HorizontalResolution drawResolution = IQuality.DRAW_RESOLUTION_DEFAULT; - + @ConfigAnnotations.FileComment public static String _lodChunkRenderDistance = IQuality.LOD_CHUNK_RENDER_DISTANCE_DESC; @ConfigAnnotations.Entry(minValue = 16, maxValue = 2048) public static int lodChunkRenderDistance = IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX.defaultValue; - + @ConfigAnnotations.FileComment public static String _verticalQuality = IQuality.VERTICAL_QUALITY_DESC; @ConfigAnnotations.Entry public static VerticalQuality verticalQuality = IQuality.VERTICAL_QUALITY_DEFAULT; - + @ConfigAnnotations.FileComment public static String _horizontalScale = IQuality.HORIZONTAL_SCALE_DESC; @ConfigAnnotations.Entry(minValue = 2, maxValue = 32) public static int horizontalScale = IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.defaultValue; - + @ConfigAnnotations.FileComment public static String _horizontalQuality = IQuality.HORIZONTAL_SCALE_DESC; @ConfigAnnotations.Entry public static HorizontalQuality horizontalQuality = IQuality.HORIZONTAL_QUALITY_DEFAULT; - + @ConfigAnnotations.FileComment public static String _dropoffQuality = IQuality.DROPOFF_QUALITY_DESC; @ConfigAnnotations.Entry public static DropoffQuality dropoffQuality = IQuality.DROPOFF_QUALITY_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_DESC; + @ConfigAnnotations.Entry(minValue = 0, maxValue = 7) + public static int lodBiomeBlending = IQuality.LOD_BIOME_BLENDING_MIN_DEFAULT_MAX.defaultValue; } - - + + public static class FogQuality { @ConfigAnnotations.FileComment public static String _fogDistance = IFogQuality.FOG_DISTANCE_DESC; @ConfigAnnotations.Entry public static FogDistance fogDistance = IFogQuality.FOG_DISTANCE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _fogDrawMode = IFogQuality.FOG_DRAW_MODE_DESC; @ConfigAnnotations.Entry public static FogDrawMode fogDrawMode = IFogQuality.FOG_DRAW_MODE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _fogColorMode = IFogQuality.FOG_COLOR_MODE_DESC; @ConfigAnnotations.Entry public static FogColorMode fogColorMode = IFogQuality.FOG_COLOR_MODE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DESC; @ConfigAnnotations.Entry public static boolean disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DEFAULT; + + @ConfigAnnotations.ScreenEntry + public static AdvancedFog advancedFog; + + public static class AdvancedFog { + static final double SQRT2 = 1.4142135623730951; + + @ConfigAnnotations.FileComment + public static String _farFogStart = IAdvancedFog.FAR_FOG_START_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double farFogStart = IAdvancedFog.FAR_FOG_START_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogEnd = IAdvancedFog.FAR_FOG_END_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double farFogEnd = IAdvancedFog.FAR_FOG_END_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogMin = IAdvancedFog.FAR_FOG_MIN_DESC; + @ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2) + public static double farFogMin = IAdvancedFog.FAR_FOG_MIN_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogMax = IAdvancedFog.FAR_FOG_MAX_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0) + public static double farFogMax = IAdvancedFog.FAR_FOG_MAX_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _farFogType = IAdvancedFog.FAR_FOG_TYPE_DESC; + @ConfigAnnotations.Entry + public static FogSetting.FogType farFogType = IAdvancedFog.FAR_FOG_TYPE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_DESC; + @ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0) + public static double farFogDensity = IAdvancedFog.FAR_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.ScreenEntry + public static HeightFog heightFog; + + public static class HeightFog { + + @ConfigAnnotations.FileComment + public static String _heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DESC; + @ConfigAnnotations.Entry + public static HeightFogMixMode heightFogMixMode = IHeightFog.HEIGHT_FOG_MIX_MODE_DEFAULT; + @ConfigAnnotations.FileComment + public static String _heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DESC; + @ConfigAnnotations.Entry + public static HeightFogMode heightFogMode = IHeightFog.HEIGHT_FOG_MODE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_DESC; + @ConfigAnnotations.Entry(minValue = -4096.0, maxValue = 4096.0) + public static double heightFogHeight = IHeightFog.HEIGHT_FOG_HEIGHT_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogStart = IHeightFog.HEIGHT_FOG_START_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double heightFogStart = IHeightFog.HEIGHT_FOG_START_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogEnd = IHeightFog.HEIGHT_FOG_END_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = SQRT2) + public static double heightFogEnd = IHeightFog.HEIGHT_FOG_END_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogMin = IHeightFog.HEIGHT_FOG_MIN_DESC; + @ConfigAnnotations.Entry(minValue = -5.0, maxValue = SQRT2) + public static double heightFogMin = IHeightFog.HEIGHT_FOG_MIN_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogMax = IHeightFog.HEIGHT_FOG_MAX_DESC; + @ConfigAnnotations.Entry(minValue = 0.0, maxValue = 5.0) + public static double heightFogMax = IHeightFog.HEIGHT_FOG_MAX_MIN_DEFAULT_MAX.defaultValue; + + @ConfigAnnotations.FileComment + public static String _heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DESC; + @ConfigAnnotations.Entry + public static FogSetting.FogType heightFogType = IHeightFog.HEIGHT_FOG_TYPE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_DESC; + @ConfigAnnotations.Entry(minValue = 0.01, maxValue = 50.0) + public static double heightFogDensity = IHeightFog.HEIGHT_FOG_DENSITY_MIN_DEFAULT_MAX.defaultValue; + + } + } } - + public static class AdvancedGraphics { @@ -155,7 +252,7 @@ public class Config public static String _disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DESC; @ConfigAnnotations.Entry public static boolean disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DEFAULT; - + @ConfigAnnotations.FileComment public static String _vanillaOverdraw = IAdvancedGraphics.VANILLA_OVERDRAW_DESC; @ConfigAnnotations.Entry @@ -170,12 +267,12 @@ public class Config public static String _brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DESC; @ConfigAnnotations.Entry public static double brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DEFAULT; - + @ConfigAnnotations.FileComment public static String _saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DESC; @ConfigAnnotations.Entry public static double saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DEFAULT; - + /* @ConfigAnnotations.FileComment public static String _backsideCullingRange = IAdvancedGraphics.VANILLA_CULLING_RANGE_DESC; @@ -184,16 +281,16 @@ public class Config */ } } - - + + public static class WorldGenerator { @ConfigAnnotations.FileComment public static String _enableDistantGeneration = IWorldGenerator.ENABLE_DISTANT_GENERATION_DESC; @ConfigAnnotations.Entry public static boolean enableDistantGeneration = IWorldGenerator.ENABLE_DISTANT_GENERATION_DEFAULT; - -// @ConfigAnnotations.FileComment + + // @ConfigAnnotations.FileComment // public static String _distanceGenerationMode = IWorldGenerator.getDistanceGenerationModeDesc(); @ConfigAnnotations.Entry public static DistanceGenerationMode distanceGenerationMode = IWorldGenerator.DISTANCE_GENERATION_MODE_DEFAULT; @@ -221,8 +318,8 @@ public class Config @ConfigAnnotations.Entry public static BlocksToAvoid blocksToAvoid = IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT; } - - + + public static class Multiplayer { @ConfigAnnotations.FileComment @@ -236,65 +333,65 @@ public class Config public static double multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DEFAULT; } - - + + public static class Advanced { @ConfigAnnotations.ScreenEntry public static Threading threading; - + @ConfigAnnotations.ScreenEntry public static Debugging debugging; - + @ConfigAnnotations.ScreenEntry public static Buffers buffers; - - + + public static class Threading { @ConfigAnnotations.FileComment public static String _numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DESC; @ConfigAnnotations.Entry(minValue = 1, maxValue = 50) public static int numberOfWorldGenerationThreads = IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue; - + @ConfigAnnotations.FileComment public static String _numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_DESC; @ConfigAnnotations.Entry(minValue = 1, maxValue = 50) public static int numberOfBufferBuilderThreads = IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX.defaultValue; } - - + + public static class Debugging { @ConfigAnnotations.FileComment public static String _drawLods = IDebugging.DRAW_LODS_DESC; @ConfigAnnotations.Entry public static boolean drawLods = IDebugging.DRAW_LODS_DEFAULT; - + @ConfigAnnotations.FileComment public static String _debugMode = IDebugging.DEBUG_MODE_DESC; @ConfigAnnotations.Entry public static DebugMode debugMode = IDebugging.DEBUG_MODE_DEFAULT; - + @ConfigAnnotations.FileComment public static String _enableDebugKeybindings = IDebugging.DEBUG_KEYBINDINGS_ENABLED_DESC; @ConfigAnnotations.Entry public static boolean enableDebugKeybindings = IDebugging.DEBUG_KEYBINDINGS_ENABLED_DEFAULT; } - - + + public static class Buffers { @ConfigAnnotations.FileComment public static String _gpuUploadMethod = IBuffers.GPU_UPLOAD_METHOD_DESC; @ConfigAnnotations.Entry public static GpuUploadMethod gpuUploadMethod = IBuffers.GPU_UPLOAD_METHOD_DEFAULT; - + @ConfigAnnotations.FileComment public static String _gpuUploadPerMegabyteInMilliseconds = IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DESC; @ConfigAnnotations.Entry(minValue = 0, maxValue = 50) public static int gpuUploadPerMegabyteInMilliseconds = IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DEFAULT.defaultValue; - + @ConfigAnnotations.FileComment public static String _rebuildTimes = IBuffers.REBUILD_TIMES_DESC; @ConfigAnnotations.Entry 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 2cd61bd18..0448c8524 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 @@ -1,5 +1,6 @@ package com.seibel.lod.common.wrappers.chunk; +import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.util.LevelPosUtil; import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; @@ -31,21 +32,21 @@ import net.minecraft.world.level.levelgen.Heightmap; */ public class ChunkWrapper implements IChunkWrapper { - private final ChunkAccess chunk; - private final LevelReader lightSource; - - - public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource) - { - this.chunk = chunk; - this.lightSource = lightSource; - } - - @Override - public int getHeight(){ - return chunk.getHeight(); - } - + private final ChunkAccess chunk; + private final LevelReader lightSource; + + + public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource) + { + this.chunk = chunk; + this.lightSource = lightSource; + } + + @Override + public int getHeight(){ + return chunk.getHeight(); + } + @Override public int getMinBuildHeight() { @@ -56,113 +57,129 @@ public class ChunkWrapper implements IChunkWrapper { return chunk.getMaxBuildHeight(); } - - @Override - public int getHeightMapValue(int xRel, int zRel) - { - return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel); - } - - @Override - public IBiomeWrapper getBiome(int x, int y, int z) - { - return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( - QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value()); - } - - @Override - public BlockDetailWrapper getBlockDetail(int x, int y, int z) { - BlockPos pos = new BlockPos(x,y,z); - BlockState blockState = chunk.getBlockState(pos); - BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); - return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; - } - - public ChunkAccess getChunk() { - return chunk; - } - - @Override - public int getChunkPosX(){ - return chunk.getPos().x; - } - - @Override - public int getChunkPosZ(){ - return chunk.getPos().z; - } - - @Override - public int getRegionPosX(){ - return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL); - } - - @Override - public int getRegionPosZ(){ - return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL); - } - - @Override - public int getMaxY(int x, int z) { - return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16)); - } - - @Override - public int getMaxX(){ - return chunk.getPos().getMaxBlockX(); - } - @Override - public int getMaxZ(){ - return chunk.getPos().getMaxBlockZ(); - } - @Override - public int getMinX(){ - return chunk.getPos().getMinBlockX(); - } - @Override - public int getMinZ() { - return chunk.getPos().getMinBlockZ(); - } - - @Override - public long getLongChunkPos() { - return chunk.getPos().toLong(); - } - - @Override - public boolean isLightCorrect(){ - //return true; - if (chunk instanceof LevelChunk) { - return ((LevelChunk) chunk).isClientLightReady(); - } - return chunk.isLightCorrect(); - } - - public boolean isWaterLogged(int x, int y, int z) - { - BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); - - //This type of block is always in water - return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock)) - && (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)); - } - - @Override - public int getEmittedBrightness(int x, int y, int z) - { - return chunk.getLightEmission(new BlockPos(x,y,z)); - } - + + @Override + public int getHeightMapValue(int xRel, int zRel) + { + return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel); + } + + @Override + public IBiomeWrapper getBiome(int x, int y, int z) + { + return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( + QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value()); + } + + @Override + public BlockDetailWrapper getBlockDetail(int x, int y, int z) { + BlockPos pos = new BlockPos(x,y,z); + BlockState blockState = chunk.getBlockState(pos); + BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; + } + + @Override + public BlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir) { + int fy = y+dir.getNormal().y; + if (fy < getMinBuildHeight() || fy > getMaxBuildHeight()) return null; + BlockPos pos = new BlockPos(x+dir.getNormal().x,fy,z+dir.getNormal().z); + BlockState blockState; + if (blockPosInsideChunk(x,y,z)) + blockState = chunk.getBlockState(pos); + else { + blockState = lightSource.getBlockState(pos); + } + if (blockState == null || blockState.isAir()) return null; + BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; + } + + public ChunkAccess getChunk() { + return chunk; + } + + @Override + public int getChunkPosX(){ + return chunk.getPos().x; + } + + @Override + public int getChunkPosZ(){ + return chunk.getPos().z; + } + + @Override + public int getRegionPosX(){ + return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL); + } + + @Override + public int getRegionPosZ(){ + return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL); + } + + @Override + public int getMaxY(int x, int z) { + return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16)); + } + + @Override + public int getMaxX(){ + return chunk.getPos().getMaxBlockX(); + } + @Override + public int getMaxZ(){ + return chunk.getPos().getMaxBlockZ(); + } + @Override + public int getMinX(){ + return chunk.getPos().getMinBlockX(); + } + @Override + public int getMinZ() { + return chunk.getPos().getMinBlockZ(); + } + + @Override + public long getLongChunkPos() { + return chunk.getPos().toLong(); + } + + @Override + public boolean isLightCorrect(){ + //return true; + if (chunk instanceof LevelChunk) { + return ((LevelChunk) chunk).isClientLightReady(); + } + return chunk.isLightCorrect(); + } + + public boolean isWaterLogged(int x, int y, int z) + { + BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); + + //This type of block is always in water + return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock)) + && (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)); + } + + @Override + public int getEmittedBrightness(int x, int y, int z) + { + return chunk.getLightEmission(new BlockPos(x,y,z)); + } + @Override public int getBlockLight(int x, int y, int z) { if (lightSource == null) return -1; - return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); + return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); } - + @Override public int getSkyLight(int x, int y, int z) { if (lightSource == null) return -1; - return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); + return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); } @Override @@ -176,10 +193,10 @@ public class ChunkWrapper implements IChunkWrapper } return true; } - + public LevelReader getColorResolver() { return lightSource; } - + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 756c11a9b..9c8f15889 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -15,47 +15,47 @@ import com.seibel.lod.common.Config; public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton { public static final LodConfigWrapperSingleton INSTANCE = new LodConfigWrapperSingleton(); - - + + private static final Client client = new Client(); @Override public IClient client() { return client; } - + public static class Client implements IClient { public final IGraphics graphics; public final IWorldGenerator worldGenerator; public final IMultiplayer multiplayer; public final IAdvanced advanced; - - + + @Override public IGraphics graphics() { return graphics; } - + @Override public IWorldGenerator worldGenerator() { return worldGenerator; } - + @Override public IMultiplayer multiplayer() { return multiplayer; } - + @Override public IAdvanced advanced() { return advanced; } - - + + @Override public boolean getOptionsButton() { @@ -67,8 +67,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("optionsButton").value = newOptionsButton; ConfigGui.editSingleOption.saveOption("optionsButton"); } - - + + //================// // Client Configs // //================// @@ -79,8 +79,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton multiplayer = new Multiplayer(); advanced = new Advanced(); } - - + + //==================// // Graphics Configs // //==================// @@ -89,36 +89,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton public final IQuality quality; public final IFogQuality fogQuality; public final IAdvancedGraphics advancedGraphics; - - - + + + @Override public IQuality quality() { return quality; } - + @Override public IFogQuality fogQuality() { return fogQuality; } - + @Override public IAdvancedGraphics advancedGraphics() { return advancedGraphics; } - - + + Graphics() { quality = new Quality(); fogQuality = new FogQuality(); advancedGraphics = new AdvancedGraphics(); } - - + + public static class Quality implements IQuality { @Override @@ -132,8 +132,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.drawResolution").value = newHorizontalResolution; ConfigGui.editSingleOption.saveOption("client.graphics.quality.drawResolution"); } - - + + @Override public int getLodChunkRenderDistance() { @@ -145,8 +145,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodChunkRenderDistance").value = newLodChunkRenderDistance; ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodChunkRenderDistance"); } - - + + @Override public VerticalQuality getVerticalQuality() { @@ -158,8 +158,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.verticalQuality").value = newVerticalQuality; ConfigGui.editSingleOption.saveOption("client.graphics.quality.verticalQuality"); } - - + + @Override public int getHorizontalScale() { @@ -171,8 +171,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalScale").value = newHorizontalScale; ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalScale"); } - - + + @Override public HorizontalQuality getHorizontalQuality() { @@ -194,11 +194,29 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.quality.dropoffQuality").value = newDropoffQuality; ConfigGui.editSingleOption.saveOption("client.graphics.quality.dropoffQuality"); } + + @Override + public int getLodBiomeBlending() { + return Config.Client.Graphics.Quality.lodBiomeBlending; + } + + @Override + public void setLodBiomeBlending(int newLodBiomeBlending) { + ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodBiomeBlending").value = newLodBiomeBlending; + ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodBiomeBlending"); + } } - - + + public static class FogQuality implements IFogQuality { + public final IAdvancedFog advancedFog; + + FogQuality() + { + advancedFog = new AdvancedFog(); + } + @Override public FogDistance getFogDistance() { @@ -210,36 +228,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDistance").value = newFogDistance; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDistance"); } - - + + @Override public FogDrawMode getFogDrawMode() { return Config.Client.Graphics.FogQuality.fogDrawMode; } - + @Override public void setFogDrawMode(FogDrawMode setFogDrawMode) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDrawMode").value = setFogDrawMode; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDrawMode"); } - - + + @Override public FogColorMode getFogColorMode() { return Config.Client.Graphics.FogQuality.fogColorMode; } - + @Override public void setFogColorMode(FogColorMode newFogColorMode) { ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogColorMode").value = newFogColorMode; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogColorMode"); } - - + + @Override public boolean getDisableVanillaFog() { @@ -251,9 +269,170 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.disableVanillaFog").value = newDisableVanillaFog; ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.disableVanillaFog"); } + + @Override + public IAdvancedFog advancedFog() { + return advancedFog; + } + + public static class AdvancedFog implements IAdvancedFog { + public final IHeightFog heightFog; + + public AdvancedFog() { + heightFog = new HeightFog(); + } + + @Override + public double getFarFogStart() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogStart; + } + @Override + public double getFarFogEnd() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogEnd; + } + @Override + public double getFarFogMin() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMin; + } + @Override + public double getFarFogMax() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax; + } + @Override + public FogSetting.FogType getFarFogType() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogType; + } + @Override + public double getFarFogDensity() { + return Config.Client.Graphics.FogQuality.AdvancedFog.farFogDensity; + } + + @Override + public void setFarFogStart(double newFarFogStart) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogStart").value = newFarFogStart; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogStart"); + } + @Override + public void setFarFogEnd(double newFarFogEnd) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogEnd").value = newFarFogEnd; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogEnd"); + } + @Override + public void setFarFogMin(double newFarFogMin) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMin").value = newFarFogMin; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMin"); + } + @Override + public void setFarFogMax(double newFarFogMax) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMax").value = newFarFogMax; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMax"); + } + @Override + public void setFarFogType(FogSetting.FogType newFarFogType) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogType").value = newFarFogType; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogType"); + } + @Override + public void setFarFogDensity(double newFarFogDensity) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogDensity").value = newFarFogDensity; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogDensity"); + } + + @Override + public IHeightFog heightFog() { + return heightFog; + } + + public static class HeightFog implements IHeightFog { + + @Override + public HeightFogMixMode getHeightFogMixMode() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMixMode; + } + @Override + public HeightFogMode getHeightFogMode() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMode; + } + @Override + public double getHeightFogHeight() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogHeight; + } + @Override + public double getHeightFogStart() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogStart; + } + @Override + public double getHeightFogEnd() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogEnd; + } + @Override + public double getHeightFogMin() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMin; + } + @Override + public double getHeightFogMax() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMax; + } + @Override + public FogSetting.FogType getHeightFogType() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogType; + } + @Override + public double getHeightFogDensity() { + return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogDensity; + } + + @Override + public void setHeightFogMixMode(HeightFogMixMode newHeightFogMixMode) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode").value = newHeightFogMixMode; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode"); + } + @Override + public void setHeightFogMode(HeightFogMode newHeightFogMode) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode").value = newHeightFogMode; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode"); + } + @Override + public void setHeightFogHeight(double newHeightFogHeight) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight").value = newHeightFogHeight; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight"); + } + @Override + public void setHeightFogStart(double newHeightFogStart) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart").value = newHeightFogStart; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart"); + } + @Override + public void setHeightFogEnd(double newHeightFogEnd) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd").value = newHeightFogEnd; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd"); + } + @Override + public void setHeightFogMin(double newHeightFogMin) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin").value = newHeightFogMin; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin"); + } + @Override + public void setHeightFogMax(double newHeightFogMax) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax").value = newHeightFogMax; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax"); + } + @Override + public void setHeightFogType(FogSetting.FogType newHeightFogType) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogType").value = newHeightFogType; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogType"); + } + @Override + public void setHeightFogDensity(double newHeightFogDensity) { + ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity").value = newHeightFogDensity; + ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity"); + } + } + } + } - - + + public static class AdvancedGraphics implements IAdvancedGraphics { @Override @@ -267,8 +446,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.disableDirectionalCulling").value = newDisableDirectionalCulling; ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.disableDirectionalCulling"); } - - + + @Override public VanillaOverdraw getVanillaOverdraw() { @@ -330,10 +509,10 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton } } } - - - - + + + + //========================// // WorldGenerator Configs // //========================// @@ -350,8 +529,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.worldGenerator.generationPriority").value = newGenerationPriority; ConfigGui.editSingleOption.saveOption("client.worldGenerator.generationPriority"); } - - + + @Override public DistanceGenerationMode getDistanceGenerationMode() { @@ -376,8 +555,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.worldGenerator.allowUnstableFeatureGeneration").value = newAllowUnstableFeatureGeneration; ConfigGui.editSingleOption.saveOption("client.worldGenerator.allowUnstableFeatureGeneration"); }*/ - - + + @Override public BlocksToAvoid getBlocksToAvoid() { @@ -412,9 +591,9 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.worldGenerator.lightGenerationMode"); } } - - - + + + //=====================// // Multiplayer Configs // //=====================// @@ -447,9 +626,9 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton } - - - + + + //============================// // AdvancedModOptions Configs // //============================// @@ -458,36 +637,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton public final IThreading threading; public final IDebugging debugging; public final IBuffers buffers; - - + + @Override public IThreading threading() { return threading; } - - + + @Override public IDebugging debugging() { return debugging; } - - + + @Override public IBuffers buffers() { return buffers; } - - + + public Advanced() { threading = new Threading(); debugging = new Debugging(); buffers = new Buffers(); } - + public static class Threading implements IThreading { @Override @@ -501,8 +680,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.threading.numberOfWorldGenerationThreads").value = newNumberOfWorldGenerationThreads; ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfWorldGenerationThreads"); } - - + + @Override public int getNumberOfBufferBuilderThreads() { @@ -515,10 +694,10 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfBufferBuilderThreads"); } } - - - - + + + + //===============// // Debug Options // //===============// @@ -535,8 +714,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value = newDrawLods; ConfigGui.editSingleOption.saveOption("client.advanced.debugging.drawLods"); } - - + + @Override public DebugMode getDebugMode() { @@ -548,8 +727,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugMode").value = newDebugMode; ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugMode"); } - - + + @Override public boolean getDebugKeybindingsEnabled() { @@ -562,11 +741,11 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.saveOption("client.advanced.debugging.enableDebugKeybindings"); } } - - + + public static class Buffers implements IBuffers { - + @Override public GpuUploadMethod getGpuUploadMethod() { @@ -578,8 +757,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadMethod").value = newDisableVanillaFog; ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadMethod"); } - - + + @Override public int getGpuUploadPerMegabyteInMilliseconds() { @@ -590,8 +769,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds").value = newMilliseconds; ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds"); } - - + + @Override public BufferRebuildTimes getRebuildTimes() { 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 e54ad7d93..f8f92d279 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 @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.stream.Collectors; +import com.mojang.blaze3d.pipeline.RenderTarget; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; import com.seibel.lod.common.wrappers.misc.LightMapWrapper; @@ -24,7 +25,6 @@ import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; import com.seibel.lod.common.wrappers.McObjectConverter; @@ -54,103 +54,123 @@ import net.minecraft.world.phys.Vec3; */ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper { - public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper(); - - private static final Minecraft MC = Minecraft.getInstance(); - private static final GameRenderer GAME_RENDERER = MC.gameRenderer; - private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE; - - @Override - public Vec3f getLookAtVector() - { - Camera camera = GAME_RENDERER.getMainCamera(); - Vector3f cameraDir = camera.getLookVector(); - return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z()); - } - - @Override - public AbstractBlockPosWrapper getCameraBlockPosition() - { - Camera camera = GAME_RENDERER.getMainCamera(); - BlockPos blockPos = camera.getBlockPosition(); - return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - } - - @Override - public boolean playerHasBlindnessEffect() - { - return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null; - } - - @Override - public Vec3d getCameraExactPosition() - { - Camera camera = GAME_RENDERER.getMainCamera(); - Vec3 projectedView = camera.getPosition(); - - return new Vec3d(projectedView.x, projectedView.y, projectedView.z); - } - - @Override - public Mat4f getDefaultProjectionMatrix(float partialTicks) - { - return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true))); - } - - @Override - public double getGamma() - { - return MC.options.gamma; - } - - @Override - public Color getFogColor(float partialTicks) { - FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks)); - float[] colorValues = RenderSystem.getShaderFogColor(); - return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]); - } - // getSpecialFogColor() is the same as getFogColor() - - @Override - public Color getSkyColor() { - if (MC.level.dimensionType().hasSkyLight()) { - Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime()); - return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); - } else - return new Color(0, 0, 0); - } - - @Override - public double getFov(float partialTicks) - { - return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true); - } - - /** Measured in chunks */ - @Override - public int getRenderDistance() - { - return MC.options.renderDistance; - } - - @Override - public int getScreenWidth() - { - return MC.getWindow().getWidth(); - } - @Override - public int getScreenHeight() - { - return MC.getWindow().getHeight(); - } - - /** - * This method returns the ChunkPos of all chunks that Minecraft - * is going to render this frame.

- *

- */ - - public boolean usingBackupGetVanillaRenderedChunks = false; + public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper(); + + private static final Minecraft MC = Minecraft.getInstance(); + private static final GameRenderer GAME_RENDERER = MC.gameRenderer; + private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE; + + @Override + public Vec3f getLookAtVector() + { + Camera camera = GAME_RENDERER.getMainCamera(); + Vector3f cameraDir = camera.getLookVector(); + return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z()); + } + + @Override + public AbstractBlockPosWrapper getCameraBlockPosition() + { + Camera camera = GAME_RENDERER.getMainCamera(); + BlockPos blockPos = camera.getBlockPosition(); + return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + } + + @Override + public boolean playerHasBlindnessEffect() + { + return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null; + } + + @Override + public Vec3d getCameraExactPosition() + { + Camera camera = GAME_RENDERER.getMainCamera(); + Vec3 projectedView = camera.getPosition(); + + return new Vec3d(projectedView.x, projectedView.y, projectedView.z); + } + + @Override + public Mat4f getDefaultProjectionMatrix(float partialTicks) + { + return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true))); + } + + @Override + public double getGamma() + { + return MC.options.gamma; + } + + @Override + public Color getFogColor(float partialTicks) { + FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks)); + float[] colorValues = RenderSystem.getShaderFogColor(); + return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]); + } + // getSpecialFogColor() is the same as getFogColor() + + @Override + public Color getSkyColor() { + if (MC.level.dimensionType().hasSkyLight()) { + Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime()); + return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z); + } else + return new Color(0, 0, 0); + } + + @Override + public double getFov(float partialTicks) + { + return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true); + } + + /** Measured in chunks */ + @Override + public int getRenderDistance() + { + return MC.options.getEffectiveRenderDistance(); + } + + @Override + public int getScreenWidth() + { + return MC.getWindow().getWidth(); + } + @Override + public int getScreenHeight() + { + return MC.getWindow().getHeight(); + } + + private RenderTarget getRenderTarget() { + RenderTarget r = null; //MC.levelRenderer.getCloudsTarget(); + return r!=null ? r : MC.getMainRenderTarget(); + } + + @Override + public int getTargetFrameBuffer() { + return getRenderTarget().frameBufferId; + } + + @Override + public int getTargetFrameBufferViewportWidth() { + return getRenderTarget().viewWidth; + } + + @Override + public int getTargetFrameBufferViewportHeight() { + return getRenderTarget().viewHeight; + } + + /** + * This method returns the ChunkPos of all chunks that Minecraft + * is going to render this frame.

+ *

+ */ + + public boolean usingBackupGetVanillaRenderedChunks = true; @Override public HashSet getVanillaRenderedChunks() { @@ -169,51 +189,51 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper } if (!usingBackupGetVanillaRenderedChunks) { try { - LevelRenderer levelRenderer = MC.levelRenderer; - LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; - return (chunks.stream().map((chunk) -> { - AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); - return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), - Math.floorDiv((int) chunkBoundingBox.minZ, 16)); - }).collect(Collectors.toCollection(HashSet::new))); + LevelRenderer levelRenderer = MC.levelRenderer; + LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; + return (chunks.stream().map((chunk) -> { + AABB chunkBoundingBox = chunk.chunk.getBoundingBox(); + return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16), + Math.floorDiv((int) chunkBoundingBox.minZ, 16)); + }).collect(Collectors.toCollection(HashSet::new))); } catch (LinkageError e) { try { - MinecraftClientWrapper.INSTANCE.sendChatMessage( + MinecraftClientWrapper.INSTANCE.sendChatMessage( "\u00A7e\u00A7l\u00A7uWARNING: Distant Horizons: getVanillaRenderedChunks method failed." - + " Using Backup Method."); - MinecraftClientWrapper.INSTANCE.sendChatMessage( + + " Using Backup Method."); + MinecraftClientWrapper.INSTANCE.sendChatMessage( "\u00A7eOverdraw prevention will be worse than normal."); } catch (Exception e2) {} - ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e); + ApiShared.LOGGER.error("getVanillaRenderedChunks Error: ", e); usingBackupGetVanillaRenderedChunks = true; } } return getMaximumRenderedChunks(); } - - @Override - public int[] getLightmapPixels() - { - LightTexture tex = GAME_RENDERER.lightTexture(); - tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug - NativeImage lightMapPixels = tex.lightPixels; - LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels); - - - int lightMapHeight = getLightmapTextureHeight(); - int lightMapWidth = getLightmapTextureWidth(); - - int[] pixels = new int[lightMapWidth * lightMapHeight]; - for (int u = 0; u < lightMapWidth; u++) - { - for (int v = 0; v < lightMapWidth; v++) - { - // this could probably be kept as a int, but - // it is easier to test and see the colors when debugging this way. - // When creating a new release this should be changed to the int version. - Color c = LodUtil.intToColor(lightMap.getLightValue(u, v)); - - // these should both create a totally white image + + @Override + public int[] getLightmapPixels() + { + LightTexture tex = GAME_RENDERER.lightTexture(); + tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug + NativeImage lightMapPixels = tex.lightPixels; + LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels); + + + int lightMapHeight = getLightmapTextureHeight(); + int lightMapWidth = getLightmapTextureWidth(); + + int[] pixels = new int[lightMapWidth * lightMapHeight]; + for (int u = 0; u < lightMapWidth; u++) + { + for (int v = 0; v < lightMapWidth; v++) + { + // this could probably be kept as a int, but + // it is easier to test and see the colors when debugging this way. + // When creating a new release this should be changed to the int version. + Color c = LodUtil.intToColor(lightMap.getLightValue(u, v)); + + // these should both create a totally white image // int col = // Integer.MAX_VALUE; // int col = @@ -221,82 +241,82 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper // (0b11111111 << 8) + // green // (0b11111111 << 16) + // blue // (0b11111111 << 24); // blue - - int col = - ((c.getRed() & 0xFF) << 16) | // blue - ((c.getGreen() & 0xFF) << 8) | // green - ((c.getBlue() & 0xFF)) | // red - ((c.getAlpha() & 0xFF) << 24); // alpha - - // 2D array stored in a 1D array. - // Thank you Tim from College ;) - pixels[u * lightMapWidth + v] = col; - } - } - - return pixels; - } - - - @Override - public int getLightmapTextureHeight() - { - int height = -1; - - LightTexture lightTexture = GAME_RENDERER.lightTexture(); - if (lightTexture != null) - { - NativeImage tex = lightTexture.lightPixels; - if (tex != null) - { - height = tex.getHeight(); - } - } - - return height; - } - - @Override - public int getLightmapTextureWidth() - { - int width = -1; - - LightTexture lightTexture = GAME_RENDERER.lightTexture(); - if (lightTexture != null) - { - NativeImage tex = lightTexture.lightPixels; - if (tex != null) - { - width = tex.getWidth(); - } - } - - return width; - } - - - @Override - public int getLightmapGLFormat() { - int glFormat = -1; - - LightTexture lightTexture = GAME_RENDERER.lightTexture(); - if (lightTexture != null) { - NativeImage tex = lightTexture.lightPixels; - if (tex != null) { - glFormat = tex.format().glFormat(); - } - } - - return glFormat; - } - - @Override - public boolean isFogStateSpecial() { - Entity entity = GAME_RENDERER.getMainCamera().getEntity(); - boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS); - return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind; - } - + + int col = + ((c.getRed() & 0xFF) << 16) | // blue + ((c.getGreen() & 0xFF) << 8) | // green + ((c.getBlue() & 0xFF)) | // red + ((c.getAlpha() & 0xFF) << 24); // alpha + + // 2D array stored in a 1D array. + // Thank you Tim from College ;) + pixels[u * lightMapWidth + v] = col; + } + } + + return pixels; + } + + + @Override + public int getLightmapTextureHeight() + { + int height = -1; + + LightTexture lightTexture = GAME_RENDERER.lightTexture(); + if (lightTexture != null) + { + NativeImage tex = lightTexture.lightPixels; + if (tex != null) + { + height = tex.getHeight(); + } + } + + return height; + } + + @Override + public int getLightmapTextureWidth() + { + int width = -1; + + LightTexture lightTexture = GAME_RENDERER.lightTexture(); + if (lightTexture != null) + { + NativeImage tex = lightTexture.lightPixels; + if (tex != null) + { + width = tex.getWidth(); + } + } + + return width; + } + + + @Override + public int getLightmapGLFormat() { + int glFormat = -1; + + LightTexture lightTexture = GAME_RENDERER.lightTexture(); + if (lightTexture != null) { + NativeImage tex = lightTexture.lightPixels; + if (tex != null) { + glFormat = tex.format().glFormat(); + } + } + + return glFormat; + } + + @Override + public boolean isFogStateSpecial() { + Entity entity = GAME_RENDERER.getMainCamera().getEntity(); + boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS); + return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind; + } + @Override public boolean tryDisableVanillaFog() { return true; // Handled via MixinFogRenderer in both forge and fabric diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java index c944503af..56f3b570b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java @@ -36,6 +36,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkSource; import net.minecraft.world.level.chunk.ChunkStatus; import org.jetbrains.annotations.Nullable; @@ -50,12 +51,12 @@ public class WorldWrapper implements IWorldWrapper private static final ConcurrentMap worldWrapperMap = new ConcurrentHashMap<>(); private final LevelAccessor world; public final WorldType worldType; - - + + public WorldWrapper(LevelAccessor newWorld) { world = newWorld; - + if (world.getClass() == ServerLevel.class) worldType = WorldType.ServerWorld; else if (world.getClass() == ClientLevel.class) @@ -63,8 +64,8 @@ public class WorldWrapper implements IWorldWrapper else worldType = WorldType.Unknown; } - - + + @Nullable public static WorldWrapper getWorldWrapper(LevelAccessor world) { @@ -72,68 +73,68 @@ public class WorldWrapper implements IWorldWrapper //first we check if the biome has already been wrapped if(worldWrapperMap.containsKey(world) && worldWrapperMap.get(world) != null) return worldWrapperMap.get(world); - - + + //if it hasn't been created yet, we create it and save it in the map WorldWrapper worldWrapper = new WorldWrapper(world); worldWrapperMap.put(world, worldWrapper); - + //we return the newly created wrapper return worldWrapper; } - + public static void clearMap() { worldWrapperMap.clear(); } - + @Override public WorldType getWorldType() { return worldType; } - + @Override public DimensionTypeWrapper getDimensionType() { return DimensionTypeWrapper.getDimensionTypeWrapper(world.dimensionType()); } - + @Override public int getBlockLight(int x, int y, int z) { return world.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z)); } - + @Override public int getSkyLight(int x, int y, int z) { return world.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); } - + public LevelAccessor getWorld() { return world; } - + @Override public boolean hasCeiling() { return world.dimensionType().hasCeiling(); } - + @Override public boolean hasSkyLight() { return world.dimensionType().hasSkyLight(); } - + @Override public int getHeight() { return world.getHeight(); } - + @Override public short getMinHeight() { @@ -146,21 +147,21 @@ public class WorldWrapper implements IWorldWrapper { if (worldType != WorldType.ServerWorld) throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds."); - + ServerChunkCache chunkSource = ((ServerLevel) world).getChunkSource(); return chunkSource.getDataStorage().dataFolder; } - - + + /** @throws UnsupportedOperationException if the WorldWrapper isn't for a ServerWorld */ public ServerLevel getServerWorld() throws UnsupportedOperationException { if (worldType != WorldType.ServerWorld) throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds."); - + return (ServerLevel) world; } - + @Override public int getSeaLevel() { @@ -169,11 +170,18 @@ public class WorldWrapper implements IWorldWrapper } @Override - public IChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) { - ChunkAccess chunk = world.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false); - if (chunk == null) return null; - return new ChunkWrapper(chunk, world); + public IChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) { + ChunkAccess chunk = world.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false); + if (chunk == null) return null; + return new ChunkWrapper(chunk, world); } - - + + @Override + public boolean hasChunkLoaded(int chunkX, int chunkZ) { + // world.hasChunk(chunkX, chunkZ); THIS DOES NOT WORK FOR CLIENT LEVEL CAUSE MOJANG ALWAYS RETURN TRUE FOR THAT! + ChunkSource source = world.getChunkSource(); + return source.hasChunk(chunkX, chunkZ); + } + + } diff --git a/core b/core index 9fa7fa843..df73d1d27 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 9fa7fa843d442f199e74cb5c38cc2ef227c53950 +Subproject commit df73d1d275ca5c3ff5b940123f719208ae214454 From b9ee54f6ad41eca7db72cee291a1a9cdc0043ddb Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 19 Mar 2022 12:39:09 -0500 Subject: [PATCH 46/48] add multi-dim and brightness/saturation --- .../java/com/seibel/lod/common/Config.java | 18 ++++++++- .../config/LodConfigWrapperSingleton.java | 40 ++++++++++++++++++- core | 2 +- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index f97d45dda..9ff8f695a 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -262,7 +262,18 @@ public class Config public static String _useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DESC; @ConfigAnnotations.Entry public static boolean useExtendedNearClipPlane = IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT; - + + @ConfigAnnotations.FileComment + public static String _brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DESC; + @ConfigAnnotations.Entry + public static double brightnessMultiplier = IAdvancedGraphics.BRIGHTNESS_MULTIPLIER_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DESC; + @ConfigAnnotations.Entry + public static double saturationMultiplier = IAdvancedGraphics.SATURATION_MULTIPLIER_DEFAULT; + + /* @ConfigAnnotations.FileComment public static String _backsideCullingRange = IAdvancedGraphics.VANILLA_CULLING_RANGE_DESC; @@ -315,6 +326,11 @@ public class Config public static String _serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DESC; @ConfigAnnotations.Entry public static ServerFolderNameMode serverFolderNameMode = IMultiplayer.SERVER_FOLDER_NAME_MODE_DEFAULT; + + @ConfigAnnotations.FileComment + public static String _multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DESC; + @ConfigAnnotations.Entry + public static double multiDimensionRequiredSimilarity = IMultiplayer.MULTI_DIMENSION_REQUIRED_SIMILARITY_DEFAULT; } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index d1ff86816..202fc6ad7 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -483,6 +483,31 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.useExtendedNearClipPlane").value = newUseExtendedNearClipPlane; ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.useExtendedNearClipPlane"); } + + @Override + public double getBrightnessMultiplier() + { + return Config.Client.Graphics.AdvancedGraphics.brightnessMultiplier; + } + @Override + public void setBrightnessMultiplier(double newBrightnessMultiplier) + { + ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.brightnessMultiplier").value = newBrightnessMultiplier; + ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.brightnessMultiplier"); + } + + @Override + public double getSaturationMultiplier() + { + return Config.Client.Graphics.AdvancedGraphics.saturationMultiplier; + } + @Override + public void setSaturationMultiplier(double newSaturationMultiplier) + { + ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.saturationMultiplier").value = newSaturationMultiplier; + ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.saturationMultiplier"); + } + } } @@ -586,8 +611,19 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton ConfigGui.editSingleOption.getEntry("client.multiplayer.serverFolderNameMode").value = newServerFolderNameMode; ConfigGui.editSingleOption.saveOption("client.multiplayer.serverFolderNameMode"); } - - + + @Override + public double getMultiDimensionRequiredSimilarity() + { + return Config.Client.Multiplayer.multiDimensionRequiredSimilarity; + } + + @Override + public void setMultiDimensionRequiredSimilarity(double newMultiDimensionMinimumSimilarityPercent) + { + ConfigGui.editSingleOption.getEntry("client.multiplayer.multiDimensionMinimumSimilarityPercent").value = newMultiDimensionMinimumSimilarityPercent; + ConfigGui.editSingleOption.saveOption("client.multiplayer.multiDimensionMinimumSimilarityPercent"); + } } diff --git a/core b/core index 804738cfe..6cd0281d0 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 804738cfe5eb7ce4312bf6cd84e559bb3f6127db +Subproject commit 6cd0281d0e1a2a76be26d166c3127b2521e8fd79 From b376014df8ab54d3e657e0fd794ab1ecf6faed2c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 19 Mar 2022 18:20:28 -0500 Subject: [PATCH 47/48] Update the manifold version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8ddcaa853..1188a0d96 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues # Global Plugin versions toml_version=3.6.4 -manifold_version=2022.1.5 +manifold_version=2022.1.7 ##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS: mcVer=1.18.2 \ No newline at end of file From 17e375bc61a1855a6a1dccaad6ba145e0a7454ee Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 19 Mar 2022 20:04:11 -0500 Subject: [PATCH 48/48] Return IBlockDetailWrappers --- .../lod/common/wrappers/chunk/ChunkWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 556db6e85..512be61bd 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 @@ -1,14 +1,15 @@ package com.seibel.lod.common.wrappers.chunk; +import com.seibel.lod.common.wrappers.block.BlockDetailWrapper; import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.util.LevelPosUtil; import com.seibel.lod.core.util.LodUtil; +import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.lod.common.wrappers.WrapperUtil; import com.seibel.lod.common.wrappers.block.BlockDetailMap; -import com.seibel.lod.common.wrappers.block.BlockDetailWrapper; import com.seibel.lod.common.wrappers.world.BiomeWrapper; import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion; @@ -77,15 +78,15 @@ public class ChunkWrapper implements IChunkWrapper } @Override - public BlockDetailWrapper getBlockDetail(int x, int y, int z) { + public IBlockDetailWrapper getBlockDetail(int x, int y, int z) { BlockPos pos = new BlockPos(x,y,z); BlockState blockState = chunk.getBlockState(pos); - BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + IBlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; } @Override - public BlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir) { + public IBlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir) { int fy = y+dir.getNormal().y; if (fy < getMinBuildHeight() || fy > getMaxBuildHeight()) return null; BlockPos pos = new BlockPos(x+dir.getNormal().x,fy,z+dir.getNormal().z); @@ -96,7 +97,7 @@ public class ChunkWrapper implements IChunkWrapper blockState = lightSource.getBlockState(pos); } if (blockState == null || blockState.isAir()) return null; - BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); + IBlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource); return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail; }