From af5bcafa45cec9654e0a1c0b503d4390a1229b14 Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Tue, 5 Apr 2022 18:14:55 +0800 Subject: [PATCH] Make 1.16 build. Confirm 1.18.X working, but others have bugs --- build.gradle | 22 +-- .../wrappers/block/BlockDetailWrapper.java | 4 +- .../block/TextureAtlasSpriteWrapper.java | 7 +- .../block/TintGetterOverrideFast.java | 33 +++-- .../block/TintGetterOverrideSmooth.java | 34 ++--- .../minecraft/MinecraftRenderWrapper.java | 6 +- .../BatchGenerationEnvironment.java | 9 +- .../mimicObject/ChunkLoader.java | 137 ++---------------- .../mimicObject/WorldGenLevelLightEngine.java | 2 +- .../WorldGenStructFeatManager.java | 4 +- .../worldGeneration/step/StepLight.java | 6 +- .../src/main/resources/1_16.lod.accesswidener | 13 +- .../com/seibel/lod/fabric/ClientProxy.java | 2 +- .../lod/fabric/mixins/MixinFogRenderer.java | 28 +++- .../lod/fabric/mixins/MixinOptionsScreen.java | 3 +- .../mixins/MixinUtilBackgroudThread.java | 4 +- .../lod/fabric/mixins/MixinWorldRenderer.java | 53 ++++--- .../mixins/events/MixinClientLevel.java | 2 +- .../mixins/events/MixinServerLevel.java | 9 ++ .../unsafe/MixinThreadingDectector.java | 5 +- .../wrappers/modAccessor/SodiumAccessor.java | 50 +++++++ 21 files changed, 219 insertions(+), 214 deletions(-) diff --git a/build.gradle b/build.gradle index fbac19506..2e1bcab3f 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,16 @@ def loadProperties() { // println "Added prop [key:" + prop.key + ", value:" + prop.value + "]" } writeBuildGradlePredefine() + + // Stuff for access wideners + def mcVersionToAcsessWidenerVersion = [ + "1.16.5": "1_16", + "1.17.1": "1_17", + "1.18.1": "1_18", + "1.18.2": "1_18", + ] + // Use this as sometimes multiple versions use the same access wideners + rootProject.ext.set("acsessWidenerVersion", mcVersionToAcsessWidenerVersion.get(mcVersion)) } loadProperties() @@ -44,14 +54,6 @@ architectury { minecraft = rootProject.minecraft_version } -// Stuff for access wideners -def mcVersionToAcsessWidenerVersion = [ - "1_16_5": "1_16", - "1_17_1": "1_17", - "1_18_1": "1_18", - "1_18_2": "1_18" -] // Use this as sometimes multiple versions use the same access wideners -def acsessWidenerVersion = mcVersionToAcsessWidenerVersion.get(minecraft_version.replace(".", "_")) subprojects { p -> apply plugin: "dev.architectury.loom" @@ -195,9 +197,9 @@ allprojects { p -> // Copies the correct accesswidener and renames it task copyAccessWidener(type: Copy) { - from project(":common").file("src/main/resources/${acsessWidenerVersion}.lod.accesswidener") + from project(":common").file("src/main/resources/${rootProject.acsessWidenerVersion}.lod.accesswidener") into(file(p.file("build/resources/main"))) - rename "${acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" + rename "${rootProject.acsessWidenerVersion}.lod.accesswidener", "lod.accesswidener" } task copyCoreResources(type: Copy) { 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 a0637d36b..9604e8570 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 @@ -246,7 +246,9 @@ public class BlockDetailWrapper extends IBlockDetailWrapper needPostTinting = quads.get(0).isTinted(); needShade = quads.get(0).isShade(); tintIndex = quads.get(0).getTintIndex(); - baseColor = calculateColorFromTexture(quads.get(0).getSprite(), + baseColor = calculateColorFromTexture( + #if MC_VERSION_1_16_5 quads.get(0).sprite, + #else quads.get(0).getSprite(), #endif ColorMode.getColorMode(state.getBlock())); } else { // Backup method. needPostTinting = false; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java index 41bcba5f5..702926a05 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java @@ -18,11 +18,16 @@ public class TextureAtlasSpriteWrapper { * The code has been modified to use TextureAtlasSprite */ public static int getPixelRGBA(TextureAtlasSprite sprite, int frameIndex, int x, int y) { + #if MC_VERSION_1_16_5 + return sprite.mainImage[0].getPixelRGBA( + x + sprite.framesX[frameIndex] * sprite.getWidth(), + y + sprite.framesY[frameIndex] * sprite.getHeight()); + #else if (sprite.animatedTexture != null) { x += sprite.animatedTexture.getFrameX(frameIndex) * sprite.width; y += sprite.animatedTexture.getFrameY(frameIndex) * sprite.height; } - return sprite.mainImage[0].getPixelRGBA(x, y); + #endif } } 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 index 0a3809f97..c03d4ce34 100644 --- 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 @@ -82,10 +82,6 @@ public class TintGetterOverrideFast implements BlockAndTintGetter { return parent.getBlockEntity(blockPos); } - @Override - public Optional getBlockEntity(BlockPos blockPos, BlockEntityType blockEntityType) { - return parent.getBlockEntity(blockPos, blockEntityType); - } @Override public BlockState getBlockState(BlockPos blockPos) { @@ -112,13 +108,6 @@ public class TintGetterOverrideFast implements BlockAndTintGetter { return parent.getBlockStates(aABB); } - #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 - @Override - public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) { - return parent.isBlockInLine(clipBlockStateContext); - } - #endif - @Override public BlockHitResult clip(ClipContext clipContext) { return parent.clip(clipContext); @@ -140,6 +129,22 @@ public class TintGetterOverrideFast implements BlockAndTintGetter { return parent.getBlockFloorHeight(blockPos); } + @Override + public int getMaxBuildHeight() { + return parent.getMaxBuildHeight(); + } + + #if !MC_VERSION_1_16_5 + @Override + public Optional getBlockEntity(BlockPos blockPos, BlockEntityType blockEntityType) { + return parent.getBlockEntity(blockPos, blockEntityType); + } + + @Override + public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) { + return parent.isBlockInLine(clipBlockStateContext); + } + @Override public int getHeight() { return parent.getHeight(); @@ -150,11 +155,6 @@ public class TintGetterOverrideFast implements BlockAndTintGetter { return parent.getMinBuildHeight(); } - @Override - public int getMaxBuildHeight() { - return parent.getMaxBuildHeight(); - } - @Override public int getSectionsCount() { return parent.getSectionsCount(); @@ -194,4 +194,5 @@ public class TintGetterOverrideFast implements BlockAndTintGetter { public int getSectionYFromSectionIndex(int i) { return parent.getSectionYFromSectionIndex(i); } + #endif } 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 index 1daa8dec3..47c1eb88d 100644 --- 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 @@ -107,11 +107,6 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter { 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); @@ -137,13 +132,6 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter { return parent.getBlockStates(aABB); } - #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2 - @Override - public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) { - return parent.isBlockInLine(clipBlockStateContext); - } - #endif - @Override public BlockHitResult clip(ClipContext clipContext) { return parent.clip(clipContext); @@ -165,6 +153,22 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter { return parent.getBlockFloorHeight(blockPos); } + @Override + public int getMaxBuildHeight() { + return parent.getMaxBuildHeight(); + } + + #if !MC_VERSION_1_16_5 + @Override + public Optional getBlockEntity(BlockPos blockPos, BlockEntityType blockEntityType) { + return parent.getBlockEntity(blockPos, blockEntityType); + } + + @Override + public BlockHitResult isBlockInLine(ClipBlockStateContext clipBlockStateContext) { + return parent.isBlockInLine(clipBlockStateContext); + } + @Override public int getHeight() { return parent.getHeight(); @@ -175,11 +179,6 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter { return parent.getMinBuildHeight(); } - @Override - public int getMaxBuildHeight() { - return parent.getMaxBuildHeight(); - } - @Override public int getSectionsCount() { return parent.getSectionsCount(); @@ -219,4 +218,5 @@ public class TintGetterOverrideSmooth implements BlockAndTintGetter { public int getSectionYFromSectionIndex(int i) { return parent.getSectionYFromSectionIndex(i); } + #endif } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java index 38f90b0ac..6c07edf14 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 @@ -1,6 +1,7 @@ package com.seibel.lod.common.wrappers.minecraft; -import java.awt.*; +import java.awt.Color; +import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.stream.Collectors; @@ -16,7 +17,6 @@ import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.client.renderer.LightTexture; import com.mojang.math.Vector3f; @@ -218,7 +218,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks; #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 - ObjectArrayList chunks = levelRenderer.renderChunks; + Collection chunks = levelRenderer.renderChunks; #endif return (chunks.stream().map((chunk) -> { #if MC_VERSION_1_18_2 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 91f9c61bf..c96939f1f 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 @@ -368,7 +368,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } if (chunkData == null) { - return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level + return new ProtoChunk(chunkPos, UpgradeData.EMPTY + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2, level #endif #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif ); } @@ -378,7 +379,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv return ChunkLoader.read(level, lightEngine, chunkPos, chunkData); } catch (Exception e) { LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); - return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level + return new ProtoChunk(chunkPos, UpgradeData.EMPTY + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2, level #endif #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null #endif ); } @@ -418,7 +420,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv // Continue... } if (target == null) - target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level + target = new ProtoChunk(chunkPos, UpgradeData.EMPTY + #if MC_VERSION_1_17_1 || MC_VERSION_1_18_1 || MC_VERSION_1_18_2, params.level #endif #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2, params.biomes, null #endif ); return target; 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 3165d16a5..637b297df 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 @@ -87,7 +87,7 @@ public class ChunkLoader biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS)); #endif #endif - int i = level.getSectionsCount(); + int i = #if MC_VERSION_1_16_5 16; #else level.getSectionsCount(); #endif LevelChunkSection[] chunkSections = new LevelChunkSection[i]; boolean isLightOn = chunkData.getBoolean("isLightOn"); @@ -125,14 +125,15 @@ public class ChunkLoader #endif chunkSections[sectionId] = new LevelChunkSection(sectionYPos, blockStateContainer, biomeContainer); } - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 if (tagSection.contains("Palette", 9) && tagSection.contains("BlockStates", 12)) { LevelChunkSection levelChunkSection = new LevelChunkSection(sectionYPos << 4); levelChunkSection.getStates().read(tagSection.getList("Palette", 10), tagSection.getLongArray("BlockStates")); levelChunkSection.recalcBlockCounts(); if (!levelChunkSection.isEmpty()) - chunkSections[level.getSectionIndexFromSectionY(sectionYPos)] = levelChunkSection; + chunkSections[#if MC_VERSION_1_16_5 sectionYPos #else level.getSectionIndexFromSectionY(sectionYPos) #endif] + = levelChunkSection; } #endif if (!isLightOn) continue; @@ -158,119 +159,6 @@ public class ChunkLoader Heightmap.primeHeightmaps(chunk, ChunkStatus.FULL.heightmapsAfter()); } - // Structures reading is disabled since... I don't think its actually useful??? - /* - #if MC_VERSION_1_18_1 - private static Map, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l) - { - HashMap, StructureStart> map = Maps.newHashMap(); - CompoundTag compoundTag2 = compoundTag.getCompound("starts"); - for (String string : compoundTag2.getAllKeys()) - { - 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) { - 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(RegistryAccess registryAccess, ChunkPos chunkPos, CompoundTag compoundTag) - { - 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", 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; - } - #endif - - #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 - 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(#if MC_VERSION_1_18_2 level.registryAccess() ,#endif chunk.getPos(), tagStructures)); - } - #endif*/ - private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData) { ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9); @@ -295,7 +183,7 @@ public class ChunkLoader public static LevelChunk read(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData) { - #if MC_VERSION_1_17_1 + #if MC_VERSION_1_16_5 || MC_VERSION_1_17_1 CompoundTag tagLevel = chunkData.getCompound("Level"); #else CompoundTag tagLevel = chunkData; @@ -321,7 +209,7 @@ public class ChunkLoader //================== Read params for making the LevelChunk ================== UpgradeData upgradeData = tagLevel.contains(TAG_UPGRADE_DATA, 10) - ? new UpgradeData(tagLevel.getCompound(TAG_UPGRADE_DATA), level) + ? new UpgradeData(tagLevel.getCompound(TAG_UPGRADE_DATA)#if !MC_VERSION_1_16_5, level #endif) : UpgradeData.EMPTY; boolean isLightOn = tagLevel.getBoolean("isLightOn"); @@ -333,21 +221,21 @@ public class ChunkLoader LevelChunkTicks fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10), string -> Registry.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos); - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 ChunkBiomeContainer chunkBiomeContainer = new ChunkBiomeContainer( - level.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), level, chunkPos, - level.getLevel().getChunkSource().getGenerator().getBiomeSource(), + level.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY)#if !MC_VERSION_1_16_5, level #endif, + chunkPos, level.getLevel().getChunkSource().getGenerator().getBiomeSource(), tagLevel.contains("Biomes", 11) ? tagLevel.getIntArray("Biomes") : null); TickList blockTicks = tagLevel.contains(BLOCK_TICKS_TAG_PRE18, 9) ? ChunkTickList.create(tagLevel.getList(BLOCK_TICKS_TAG_PRE18, 10), Registry.BLOCK::getKey, Registry.BLOCK::get) : new ProtoTickList(block -> (block == null || block.defaultBlockState().isAir()), chunkPos, - tagLevel.getList("ToBeTicked", 9), level); + tagLevel.getList("ToBeTicked", 9)#if !MC_VERSION_1_16_5, level #endif); TickList fluidTicks = tagLevel.contains(FLUID_TICKS_TAG_PRE18, 9) ? ChunkTickList.create(tagLevel.getList(FLUID_TICKS_TAG_PRE18, 10), Registry.FLUID::getKey, Registry.FLUID::get) : new ProtoTickList(fluid -> (fluid == null || fluid == Fluids.EMPTY), chunkPos, - tagLevel.getList("LiquidsToBeTicked", 9), level); + tagLevel.getList("LiquidsToBeTicked", 9)#if !MC_VERSION_1_16_5, level #endif); #endif LevelChunkSection[] levelChunkSections = readSections(level, lightEngine, chunkPos, tagLevel); @@ -363,9 +251,6 @@ public class ChunkLoader #endif // Set some states after object creation - //#if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 - //readStructures(level, chunk, chunkData); - //#endif chunk.setLightCorrect(isLightOn); readHeightmaps(chunk, chunkData); readPostPocessings(chunk, chunkData); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java index acbca3b30..da2e20308 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenLevelLightEngine.java @@ -146,7 +146,7 @@ public class WorldGenLevelLightEngine extends LevelLightEngine { int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i); updateSectionStatus(SectionPos.of(chunkPos, j), false); } - #elif MC_VERSION_1_18_1 || MC_VERSION_1_18_1 + #elif MC_VERSION_1_18_1 || MC_VERSION_1_18_2 if (levelChunkSection.hasOnlyAir()) continue; int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i); updateSectionStatus(SectionPos.of(chunkPos, j), false); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java index 1273a1e1d..7072a14ed 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java @@ -58,7 +58,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { return this; #if MC_VERSION_1_18_2 || MC_VERSION_1_18_1 return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion, structureCheck); - #elif MC_VERSION_1_17_1 + #elif MC_VERSION_1_16_5 || MC_VERSION_1_17_1 return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion); #endif } @@ -79,7 +79,7 @@ public class WorldGenStructFeatManager extends StructureFeatureManager { #endif - #if MC_VERSION_1_17_1 + #if MC_VERSION_1_16_5 || MC_VERSION_1_17_1 @Override public Stream> startsForFeature(SectionPos sectionPos2, StructureFeature structureFeature) { 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 c52d01dee..6dc8e8f4e 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 @@ -9,6 +9,7 @@ import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.ProtoChunk; +import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.lighting.LightEventListener; public final class StepLight { @@ -27,9 +28,10 @@ public final class StepLight { public final ChunkStatus STATUS = ChunkStatus.LIGHT; - public void generateGroup(LightEventListener lightEngine, + public void generateGroup( + #if MC_VERSION_1_16_5 LevelLightEngine lightEngine, + #else LightEventListener lightEngine, #endif ArrayGridList chunks) { - //ArrayList chunksToDo = new ArrayList(); for (ChunkAccess chunk : chunks) { if (chunk.getStatus().isOrAfter(STATUS)) continue; diff --git a/common/src/main/resources/1_16.lod.accesswidener b/common/src/main/resources/1_16.lod.accesswidener index 9fc43d639..22911b192 100644 --- a/common/src/main/resources/1_16.lod.accesswidener +++ b/common/src/main/resources/1_16.lod.accesswidener @@ -28,7 +28,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 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 @@ -36,13 +36,10 @@ accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSecti accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop; accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag; - # grabbing textures -accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite animatedTexture Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture; -accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite width I -accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite height I +accessible field net/minecraft/client/renderer/block/model/BakedQuad sprite Lnet/minecraft/client/renderer/texture/TextureAtlasSprite; +accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite framesX [I +accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite framesY [I accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage; -accessible class net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture -accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameX (I)I -accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameY (I)I + extendable class com/mojang/math/Matrix4f \ No newline at end of file diff --git a/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java b/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java index 117c15bdd..c3c658e60 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java @@ -78,7 +78,7 @@ public class ClientProxy /* World Events */ //ServerChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent); - #if MC_VERSION_1_17_1 + #if MC_VERSION_1_16_5 || MC_VERSION_1_17_1 ClientChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent); #endif diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java index 26fe25a70..09b1e6be0 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinFogRenderer.java @@ -15,7 +15,12 @@ import net.minecraft.client.renderer.FogRenderer.FogMode; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; +#if MC_VERSION_1_16_5 +import net.minecraft.tags.FluidTags; +import net.minecraft.world.level.material.FluidState; +#else import net.minecraft.world.level.material.FogType; +#endif @Mixin(FogRenderer.class) public class MixinFogRenderer { @@ -24,7 +29,26 @@ public class MixinFogRenderer { // Using this instead of Float.MAX_VALUE because Sodium don't like it. private static final float A_REALLY_REALLY_BIG_VALUE = 420694206942069.F; private static final float A_EVEN_LARGER_VALUE = 42069420694206942069.F; - + + #if MC_VERSION_1_16_5 + + @Inject(at = @At("RETURN"), method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZ)V") + private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback) { + FluidState fluidState = camera.getFluidInCamera(); + Entity entity = camera.getEntity(); + boolean isUnderWater = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS); + isUnderWater |= fluidState.is(FluidTags.WATER); + isUnderWater |= fluidState.is(FluidTags.LAVA); + + if (!isUnderWater) { + if (fogMode == FogMode.FOG_TERRAIN && CONFIG.client().graphics().fogQuality().getDisableVanillaFog()) { + RenderSystem.fogStart(A_REALLY_REALLY_BIG_VALUE); + RenderSystem.fogEnd(A_EVEN_LARGER_VALUE); + } + } + } + + #else @Inject(at = @At("RETURN"), method = "setupFog(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/FogRenderer$FogMode;FZ)V") private static void disableSetupFog(Camera camera, FogMode fogMode, float f, boolean bl, CallbackInfo callback) { FogType fogTypes = camera.getFluidInCamera(); @@ -37,4 +61,6 @@ public class MixinFogRenderer { } } } + #endif + } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java index 31f222020..540040365 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java @@ -34,7 +34,8 @@ public class MixinOptionsScreen extends Screen { @Inject(at = @At("HEAD"),method = "init") private void lodconfig$init(CallbackInfo ci) { if (SingletonHandler.get(ILodConfigWrapperSingleton.class).client().getOptionsButton()) - this.addRenderableWidget(new TexturedButtonWidget( + this. #if MC_VERSION_1_16_5 addButton #else addRenderableWidget #endif + (new TexturedButtonWidget( // Where the button is on the screen this.width / 2 - 180, this.height / 6 - 12, // Width and height of the button 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 120ffef09..6aec98033 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 @@ -16,7 +16,8 @@ import net.minecraft.Util; @Mixin(Util.class) public class MixinUtilBackgroudThread { - + + #if !MC_VERSION_1_16_5 @Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;", at = @At("HEAD"), cancellable = true) private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable ci) @@ -27,6 +28,7 @@ public class MixinUtilBackgroudThread ci.setReturnValue(r); } } + #endif #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 @Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;", at = @At("HEAD"), cancellable = true) 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 5a370eed4..93626c86d 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 @@ -28,6 +28,7 @@ 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.lwjgl.opengl.GL15; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -55,6 +56,40 @@ public class MixinWorldRenderer throw new NullPointerException("Null cannot be cast to non-null type."); } + + // Inject rendering at first call to renderChunkLayer + // HEAD or RETURN + #if MC_VERSION_1_16_5 + @Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V") + private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback) + { + // get the partial ticks since renderBlockLayer doesn't + // have access to them + previousPartialTicks = partialTicks; + } + + @Inject(at = @At("HEAD"), + method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V", + cancellable = true) + private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback) + { + // only render before solid blocks + if (renderType.equals(RenderType.solid())) + { + // get MC's current projection matrix + float[] mcProjMatrixRaw = new float[16]; + GL15.glGetFloatv(GL15.GL_PROJECTION_MATRIX, mcProjMatrixRaw); + Mat4f mcProjectionMatrix = new Mat4f(mcProjMatrixRaw); + mcProjectionMatrix.transpose(); + Mat4f mcModelViewMatrix = McObjectConverter.Convert(matrixStackIn.last().pose()); + + ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks); + } + if (Config.Client.Advanced.lodOnlyMode) { + callback.cancel(); + } + } + #else @Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true) public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) { // get the partial ticks since renderChunkLayer doesn't @@ -62,23 +97,6 @@ public class MixinWorldRenderer previousPartialTicks = tickDelta; } - /* Inject rendering at renderSky - // HEAD or RETURN - @Inject(at = @At("RETURN"), - method = "renderSky", - cancellable = true) - 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); - - ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks); - - }*/ - - // Inject rendering at first call to renderChunkLayer - // HEAD or RETURN @Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V", cancellable = true) @@ -96,4 +114,5 @@ public class MixinWorldRenderer callback.cancel(); } } + #endif } 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 54ed41fc6..bdc8d8969 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 @@ -44,7 +44,7 @@ public class MixinClientLevel { #endif #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 - @Inject(method = "setLightReady", at = @At("RETURN")) + @Inject(method = "setLightReady", at = @At("HEAD")) private void onChunkLightReady(int x, int z, CallbackInfo ci) { ClientLevel l = (ClientLevel) (Object) this; LevelChunk chunk = l.getChunkSource().getChunk(x, z, false); diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinServerLevel.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinServerLevel.java index 21929f60e..052c3bd36 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinServerLevel.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinServerLevel.java @@ -14,6 +14,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; */ @Mixin(ServerLevel.class) public class MixinServerLevel { + #if MC_VERSION_1_16_5 + + @Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerChunkCache;save(Z)V", shift = At.Shift.AFTER)) + private void saveWorldEvent(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) { + Main.client_proxy.worldSaveEvent(); + } + + #else @Inject(method = "save", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;saveAll()V", shift = At.Shift.AFTER)) private void saveWorldEvent_sA(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) { Main.client_proxy.worldSaveEvent(); @@ -23,4 +31,5 @@ public class MixinServerLevel { private void saveWorldEvent_aS(ProgressListener progressListener, boolean bl, boolean bl2, CallbackInfo ci) { Main.client_proxy.worldSaveEvent(); } + #endif } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/unsafe/MixinThreadingDectector.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/unsafe/MixinThreadingDectector.java index cd25640c3..ad70df903 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/unsafe/MixinThreadingDectector.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/unsafe/MixinThreadingDectector.java @@ -1,10 +1,11 @@ package com.seibel.lod.fabric.mixins.unsafe; -import net.minecraft.util.ThreadingDetector; +import net.minecraft.server.level.ServerLevel; import org.spongepowered.asm.mixin.Mixin; #if MC_VERSION_1_18_1 || MC_VERSION_1_18_2 +import net.minecraft.util.ThreadingDetector; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -28,6 +29,6 @@ public class MixinThreadingDectector { } } #else -@Mixin(ThreadingDetector.class) +@Mixin(ServerLevel.class) public class MixinThreadingDectector {} //FIXME: Is there some way to make this file just not be added? #endif diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java index 6e10ce76f..8ebc19b2c 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java @@ -12,7 +12,16 @@ import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; import net.minecraft.client.Minecraft; +#if MC_VERSION_1_16_5 +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.protocol.Packet; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.phys.AABB; +#else import net.minecraft.world.level.LevelHeightAccessor; +#endif public class SodiumAccessor implements ISodiumAccessor { private final IWrapperFactory factory = SingletonHandler.get(IWrapperFactory.class); @@ -23,6 +32,7 @@ public class SodiumAccessor implements ISodiumAccessor { return "Sodium-Fabric"; } + #if !MC_VERSION_1_16_5 @Override public HashSet getNormalRenderedChunks() { SodiumWorldRenderer renderer = SodiumWorldRenderer.instance(); @@ -45,4 +55,44 @@ public class SodiumAccessor implements ISodiumAccessor { }).collect(Collectors.toCollection(HashSet::new)); #endif } + #else + @Override + public HashSet getNormalRenderedChunks() { + SodiumWorldRenderer renderer = SodiumWorldRenderer.getInstance(); + LevelAccessor height = Minecraft.getInstance().level; + // TODO: Maybe use a mixin to make this more efficient + return MC_RENDER.getMaximumRenderedChunks().stream().filter((AbstractChunkPosWrapper chunk) -> { + FakeChunkEntity AABB = new FakeChunkEntity(chunk.getX(), chunk.getZ(), height.getMaxBuildHeight()); + return (renderer.isEntityVisible(AABB)); + }).collect(Collectors.toCollection(HashSet::new)); + } + + private static class FakeChunkEntity extends Entity { + public int cx; + public int cz; + public int my; + public FakeChunkEntity(int chunkX, int chunkZ, int maxHeight) { + super(EntityType.AREA_EFFECT_CLOUD, null); + cx = chunkX; + cz = chunkZ; + my = maxHeight; + } + @Override + public AABB getBoundingBoxForCulling() { + return new AABB(cx*16+1, 1, cz*16+1, + cx*16+15, my-1, cz*16+15); + } + @Override + protected void defineSynchedData() {} + @Override + protected void readAdditionalSaveData(CompoundTag paramCompoundTag) {} + @Override + protected void addAdditionalSaveData(CompoundTag paramCompoundTag) {} + @Override + public Packet getAddEntityPacket() { + throw new UnsupportedOperationException("This is a FAKE CHUNK ENTITY... For tricking the Sodium to check a AABB."); + } + } + #endif + }