Reverted the commit that added 1.18.2 to this branch

This commit is contained in:
coolGi2007
2022-03-02 18:08:11 +10:30
parent 25d2cfd7b8
commit b97b1b61b7
12 changed files with 119 additions and 130 deletions
@@ -211,7 +211,7 @@ public class BlockDetailMap
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();
Biome biome = getter.getBiome(pos);
BlockDetail tintDetail = biomeDetailMap.get(biome);
if (tintDetail == null) {
if (!bs.getFluidState().isEmpty()) bs = bs.getFluidState().createLegacyBlock();
@@ -61,7 +61,7 @@ public class ChunkWrapper implements IChunkWrapper
public IBiomeWrapper getBiome(int x, int y, int z)
{
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value());
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
}
@Override
@@ -172,7 +172,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
LevelRenderer levelRenderer = MC.levelRenderer;
LinkedHashSet<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunkStorage.get().renderChunks;
return (chunks.stream().map((chunk) -> {
AABB chunkBoundingBox = chunk.chunk.getBoundingBox();
AABB chunkBoundingBox = chunk.chunk.bb;
return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16),
Math.floorDiv((int) chunkBoundingBox.minZ, 16));
}).collect(Collectors.toCollection(HashSet::new)));
@@ -65,7 +65,7 @@ public class BiomeWrapper implements IBiomeWrapper
{
int colorInt;
switch (biome.biomeCategory)
switch (biome.getBiomeCategory())
{
case NETHER:
@@ -5,6 +5,7 @@ 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;
@@ -14,7 +15,6 @@ 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.SectionPos;
import net.minecraft.nbt.CompoundTag;
@@ -39,7 +39,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;
@@ -55,7 +54,7 @@ public class ChunkLoader
private static final String TAG_UPGRADE_DATA = "UpgradeData";
private static final String BLOCK_TICKS_TAG = "block_ticks";
private static final String FLUID_TICKS_TAG = "fluid_ticks";
private static BlendingData readBlendingData(CompoundTag chunkData)
{
BlendingData blendingData = null;
@@ -67,53 +66,52 @@ public class ChunkLoader
}
return blendingData;
}
private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
{
// Registry<Biome> biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
// Codec<PalettedContainer<Biome>> 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<BlockState> blockStateContainer;
// PalettedContainer<Holder<Biome>> 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<BlockState>(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, sectionYPos, string)).getOrThrow(false, LOGGER::error)
// : new PalettedContainer<Holder<Biome>>(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;
Registry<Biome> biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
Codec<PalettedContainer<Biome>> 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<BlockState> blockStateContainer;
PalettedContainer<Biome> 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<BlockState>(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, sectionYPos, string)).getOrThrow(false, LOGGER::error)
: new PalettedContainer<Biome>(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;
}
private static void readHeightmaps(LevelChunk chunk, CompoundTag chunkData)
{
CompoundTag tagHeightmaps = chunkData.getCompound("Heightmaps");
@@ -125,58 +123,55 @@ public class ChunkLoader
}
Heightmap.primeHeightmaps(chunk, ChunkStatus.FULL.heightmapsAfter());
}
private static Map<ConfiguredStructureFeature<?, ?>, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l)
private static Map<StructureFeature<?>, StructureStart<?>> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l)
{
// Map<ConfiguredStructureFeature<?, ?>, StructureStart> map = Maps.newHashMap();
// CompoundTag compoundTag2 = compoundTag.getCompound("starts");
// for (String string : compoundTag2.getAllKeys())
// {
// 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;
HashMap<StructureFeature<?>, 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<ConfiguredStructureFeature<?, ?>, LongSet> unpackStructureReferences(ChunkPos chunkPos, CompoundTag compoundTag)
private static Map<StructureFeature<?>, LongSet> unpackStructureReferences(ChunkPos chunkPos, CompoundTag compoundTag)
{
// Map<ConfiguredStructureFeature<?, ?>, LongSet> map = Maps.newHashMap();
// CompoundTag compoundTag2 = compoundTag.getCompound("References");
// for (String string : compoundTag2.getAllKeys())
// {
// 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;
HashMap<StructureFeature<?>, 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;
}
private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData)
{
CompoundTag tagStructures = chunkData.getCompound("structures");
@@ -184,7 +179,7 @@ public class ChunkLoader
unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed()));
chunk.setAllReferences(unpackStructureReferences(chunk.getPos(), tagStructures));
}
private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData)
{
ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9);
@@ -197,32 +192,32 @@ public class ChunkLoader
}
}
}
public static ChunkStatus.ChunkType readChunkType(CompoundTag compoundTag)
{
return ChunkStatus.byName(compoundTag.getString("Status")).getChunkType();
}
public static LevelChunk read(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
{
ChunkPos actualPos = new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos"));
if (!Objects.equals(chunkPos, actualPos))
{
LOGGER.error("Distant Horizons: Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", (Object) chunkPos, (Object) chunkPos, (Object) actualPos);
return null;
}
ChunkStatus.ChunkType chunkType = readChunkType(chunkData);
BlendingData blendingData = readBlendingData(chunkData);
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise()))
return null;
// Prepare the light engine
boolean isLightOn = chunkData.getBoolean("isLightOn");
if (isLightOn)
level.getLightEngine().retainData(chunkPos, true);
// Read params for making the LevelChunk
UpgradeData upgradeData = chunkData.contains(TAG_UPGRADE_DATA, 10)
? new UpgradeData(chunkData.getCompound(TAG_UPGRADE_DATA), level)
@@ -233,10 +228,10 @@ public class ChunkLoader
string -> Registry.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos);
long inhabitedTime = chunkData.getLong("InhabitedTime");
LevelChunkSection[] chunkSections = readSections(level, lightEngine, actualPos, chunkData);
// Make chunk
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks, fluidTicks, inhabitedTime, chunkSections, null, blendingData);
// Set some states after object creation
chunk.setLightCorrect(isLightOn);
readHeightmaps(chunk, chunkData);
@@ -244,7 +239,7 @@ public class ChunkLoader
readPostPocessings(chunk, chunkData);
return chunk;
}
private static void logErrors(ChunkPos chunkPos, int i, String string)
{
LOGGER.error("Distant Horizons: Recoverable errors when loading section [" + chunkPos.x + ", " + i + ", " + chunkPos.z + "]: " + string);
@@ -78,12 +78,11 @@ public class LightedWorldGenRegion extends WorldGenRegion {
return true;
}
// TODO Check this
// @Override
// public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
// StructureFeature<?> structureFeature) {
// return structFeat.startsForFeature(sectionPos, structureFeature);
// }
@Override
public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
StructureFeature<?> structureFeature) {
return structFeat.startsForFeature(sectionPos, structureFeature);
}
// Skip updating the related tile entities
@Override
@@ -52,8 +52,6 @@ public class WorldGenStructFeatManager extends StructureFeatureManager {
return chunk.hasAnyStructureReferences();
}
// TODO Check this
/*
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public List<? extends StructureStart<?>> startsForFeature(SectionPos sectionPos,
@@ -78,5 +76,4 @@ public class WorldGenStructFeatManager extends StructureFeatureManager {
}
return builder.build();
}
*/
}
+1 -2
View File
@@ -22,10 +22,9 @@ accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine L
# world generation
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Ljava/util/function/Supplier;
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/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
# lod generation from save file
@@ -4,7 +4,6 @@ import com.seibel.lod.fabric.Main;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.dimension.DimensionType;
@@ -22,7 +21,7 @@ import java.util.function.Supplier;
@Mixin(ClientLevel.class)
public class MixinClientLevel {
@Inject(method = "<init>", 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) {
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);
}
@Inject(method = "setLightReady", at = @At("HEAD"))
+1 -1
View File
@@ -34,7 +34,7 @@
"depends": {
"fabricloader": "*",
"fabric": "*",
"minecraft": "1.18.2",
"minecraft": ["1.18", "1.18.1"],
"java": ">=17"
},
"suggests": {
+1 -1
View File
@@ -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="[37,40)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="GNU GPLv3"
issueTrackerURL="${issues}"
+6 -6
View File
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx2048M
minecraft_version=1.18.2
minecraft_version=1.18.1
archives_base_name=DistantHorizons
mod_version=1.6.2a
@@ -16,13 +16,13 @@ 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_loader_version=0.13.2
fabric_api_version=0.46.4+1.18
# Fabric mod versions
modmenu_version=3.1.0
modmenu_version=3.0.1
starlight_version_fabric=3554912
lithium_version=mc1.18.1-0.7.7
sodium_version=3669187
sodium_version=3605309
iris_version=1.18.x-v1.1.4
bclib_version=1.2.5
immersive_portals_version = v1.0.4-1.18
@@ -38,7 +38,7 @@ fabric_api_version=0.47.8+1.18.2
enable_bclib=0
# Forge loader
forge_version=40.0.1
forge_version=39.0.76
# Forge mod versions
starlight_version_forge=3559934