From 35bb5cdc92369ec996303c9d37a2f1b5c3f0f93e Mon Sep 17 00:00:00 2001 From: tom lee Date: Wed, 19 Jan 2022 19:01:50 +0800 Subject: [PATCH] Update core --- .../common/wrappers/chunk/ChunkWrapper.java | 42 +++++++++---------- .../worldGeneration/WorldGenerationStep.java | 15 ++++--- core | 2 +- 3 files changed, 31 insertions(+), 28 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 eb9c81c97..266e49312 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 @@ -10,6 +10,7 @@ import com.seibel.lod.common.wrappers.block.BlockShapeWrapper; import com.seibel.lod.common.wrappers.world.BiomeWrapper; import net.minecraft.core.BlockPos; +import net.minecraft.core.QuartPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.block.Block; @@ -32,25 +33,22 @@ public class ChunkWrapper implements IChunkWrapper { private final ChunkAccess chunk; private final BlockAndTintGetter lightSource; - private final int CHUNK_SECTION_SHIFT = 4; - private final int CHUNK_SECTION_MASK = 0b1111; - private final int CHUNK_SIZE_SHIFT = 4; - private final int CHUNK_SIZE_MASK = 0b1111; @Override public int getHeight(){ - return chunk.getMaxBuildHeight(); + return chunk.getHeight(); } - @Override - public boolean isPositionInWater(int x, int y, int z) - { - BlockState blockState = chunk.getSections()[y >> CHUNK_SECTION_SHIFT].getBlockState(x & CHUNK_SIZE_MASK, y & CHUNK_SECTION_MASK, z & CHUNK_SIZE_MASK); - - //This type of block could be in water - return blockState.getBlock() instanceof LiquidBlock // && !(blockState.getBlock() instanceof IWaterLoggable)) - || (blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).isPresent() && blockState.getOptionalValue(BlockStateProperties.WATERLOGGED).get()); - } + @Override + public int getMinBuildHeight() + { + return chunk.getMinBuildHeight(); + } + @Override + public int getMaxBuildHeight() + { + return chunk.getMaxBuildHeight(); + } @Override public int getHeightMapValue(int xRel, int zRel) @@ -61,22 +59,23 @@ public class ChunkWrapper implements IChunkWrapper @Override public IBiomeWrapper getBiome(int x, int y, int z) { - return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome((x & CHUNK_SIZE_MASK) >> 2, y >> 2, (z & CHUNK_SIZE_MASK) >> 2)); + return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome( + QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z))); } @Override public IBlockColorWrapper getBlockColorWrapper(int x, int y, int z) { - Block block = chunk.getSections()[y >> CHUNK_SECTION_SHIFT].getBlockState(x & CHUNK_SIZE_MASK, y & CHUNK_SECTION_MASK, z & CHUNK_SIZE_MASK).getBlock(); + BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); + Block block = blockState.getBlock(); return BlockColorWrapper.getBlockColorWrapper(block); } @Override public IBlockShapeWrapper getBlockShapeWrapper(int x, int y, int z) { - LevelChunkSection section = chunk.getSections()[y >> CHUNK_SECTION_SHIFT]; - if (section == null) return null; - Block block = section.getBlockState(x & CHUNK_SIZE_MASK, y & CHUNK_SECTION_MASK, z & CHUNK_SIZE_MASK).getBlock(); + BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z)); + Block block = blockState.getBlock(); return BlockShapeWrapper.getBlockShapeWrapper(block, this, x, y, z); } @@ -154,9 +153,7 @@ public class ChunkWrapper implements IChunkWrapper public boolean isWaterLogged(int x, int y, int z) { - LevelChunkSection section = chunk.getSections()[y >> CHUNK_SECTION_SHIFT]; - if (section == null) return false; - BlockState blockState = section.getBlockState(x & CHUNK_SIZE_MASK, y & CHUNK_SECTION_MASK, z & CHUNK_SIZE_MASK); + 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)) @@ -180,4 +177,5 @@ public class ChunkWrapper implements IChunkWrapper if (lightSource == null) return -1; return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z)); } + } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java index 215d52535..ba2cbd4ed 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGenerationStep.java @@ -19,6 +19,7 @@ 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.api.ModAccessorApi; import com.seibel.lod.core.builders.lodBuilding.LodBuilder; @@ -536,14 +537,18 @@ public final class WorldGenerationStep { return; } int centreIndex = referencedChunks.size() / 2; - + // System.out.println("Lod Generate Event: "+event); - for (int oy = -e.range; oy <= e.range; oy++) { - for (int ox = -e.range; ox <= e.range; ox++) { + for (int oy = -e.range; oy <= e.range; oy++) + { + for (int ox = -e.range; ox <= e.range; ox++) + { int targetIndex = referencedChunks.offsetOf(centreIndex, ox, oy); ChunkAccess target = referencedChunks.get(targetIndex); - params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region), - new LodBuilderConfig(generationMode), false); + params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region), new LodBuilderConfig(generationMode) + , false); + //params.lodBuilder.generateLodNodeAsync(new ChunkWrapper(target, region), ApiShared.lodWorld, params.lodDim.dimension, + // generationMode, false, () -> {}, () -> {}); } } e.pEvent.endNano = System.nanoTime(); diff --git a/core b/core index 930113a6f..22e47b973 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 930113a6f990163acf30bf74cf6793a0d0d5e36d +Subproject commit 22e47b9734011c611056570be9b32f025a94fe08