Prep for MC 1.21.3 support
This commit is contained in:
+7
-7
@@ -141,7 +141,7 @@ public class LodDataBuilder
|
||||
for (int relBlockZ = 0; relBlockZ < LodUtil.CHUNK_WIDTH; relBlockZ++)
|
||||
{
|
||||
LongArrayList longs = new LongArrayList(chunkWrapper.getHeight() / 4);
|
||||
int lastY = chunkWrapper.getMaxBuildHeight();
|
||||
int lastY = chunkWrapper.getExclusiveMaxBuildHeight();
|
||||
IBiomeWrapper biome = chunkWrapper.getBiome(relBlockX, lastY, relBlockZ);
|
||||
IBlockStateWrapper blockState = AIR;
|
||||
int mappedId = dataSource.mapping.addIfNotPresentAndGetId(biome, blockState);
|
||||
@@ -149,7 +149,7 @@ public class LodDataBuilder
|
||||
|
||||
byte blockLight;
|
||||
byte skyLight;
|
||||
if (lastY < chunkWrapper.getMaxBuildHeight())
|
||||
if (lastY < chunkWrapper.getExclusiveMaxBuildHeight())
|
||||
{
|
||||
// FIXME: The lastY +1 offset is to reproduce the old behavior. Remove this when we get per-face lighting
|
||||
blockLight = (byte) chunkWrapper.getDhBlockLight(relBlockX, lastY + 1, relBlockZ);
|
||||
@@ -167,7 +167,7 @@ public class LodDataBuilder
|
||||
int y = chunkWrapper.getLightBlockingHeightMapValue(relBlockX, relBlockZ);
|
||||
// go up until we reach open air or the world limit
|
||||
IBlockStateWrapper topBlockState = previousBlockState = chunkWrapper.getBlockState(relBlockX, y, relBlockZ, mcBlockPos, previousBlockState);
|
||||
while (!topBlockState.isAir() && y < chunkWrapper.getMaxBuildHeight())
|
||||
while (!topBlockState.isAir() && y < chunkWrapper.getExclusiveMaxBuildHeight())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -180,7 +180,7 @@ public class LodDataBuilder
|
||||
{
|
||||
if (!getTopErrorLogged)
|
||||
{
|
||||
LOGGER.warn("Unexpected issue in LodDataBuilder, future errors won't be logged. Chunk [" + chunkWrapper.getChunkPos() + "] with max height: [" + chunkWrapper.getMaxBuildHeight() + "] had issue getting block at pos [" + relBlockX + "," + y + "," + relBlockZ + "] error: " + e.getMessage(), e);
|
||||
LOGGER.warn("Unexpected issue in LodDataBuilder, future errors won't be logged. Chunk [" + chunkWrapper.getChunkPos() + "] with max height: [" + chunkWrapper.getExclusiveMaxBuildHeight() + "] had issue getting block at pos [" + relBlockX + "," + y + "," + relBlockZ + "] error: " + e.getMessage(), e);
|
||||
getTopErrorLogged = true;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public class LodDataBuilder
|
||||
// check if this block is visible from any direction
|
||||
|| blockVisible(chunkWrapper, relBlockX, y, relBlockZ))
|
||||
{
|
||||
longs.add(FullDataPointUtil.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getMinBuildHeight(), blockLight, skyLight));
|
||||
longs.add(FullDataPointUtil.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getInclusiveMinBuildHeight(), blockLight, skyLight));
|
||||
biome = newBiome;
|
||||
blockState = newBlockState;
|
||||
|
||||
@@ -219,7 +219,7 @@ public class LodDataBuilder
|
||||
}
|
||||
}
|
||||
}
|
||||
longs.add(FullDataPointUtil.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getMinBuildHeight(), blockLight, skyLight));
|
||||
longs.add(FullDataPointUtil.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getInclusiveMinBuildHeight(), blockLight, skyLight));
|
||||
|
||||
dataSource.setSingleColumn(longs,
|
||||
relBlockX + chunkOffsetX,
|
||||
@@ -289,7 +289,7 @@ public class LodDataBuilder
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (testBlockPos.getY() < chunkWrapper.getMinBuildHeight() || testBlockPos.getY() > chunkWrapper.getMaxBuildHeight())
|
||||
if (testBlockPos.getY() < chunkWrapper.getInclusiveMinBuildHeight() || testBlockPos.getY() > chunkWrapper.getExclusiveMaxBuildHeight())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public class DhLightingEngine
|
||||
IBlockStateWrapper previousBlockState = null;
|
||||
|
||||
int maxY = chunk.getMaxNonEmptyHeight();
|
||||
int minY = chunk.getMinBuildHeight();
|
||||
int minY = chunk.getInclusiveMinBuildHeight();
|
||||
|
||||
// get the adjacent chunk's sky lights
|
||||
for (int relX = 0; relX < LodUtil.CHUNK_WIDTH; relX++) // relative block pos
|
||||
@@ -322,7 +322,7 @@ public class DhLightingEngine
|
||||
continue;
|
||||
}
|
||||
|
||||
if (relNeighbourBlockPos.getY() < neighbourChunk.getMinNonEmptyHeight() || relNeighbourBlockPos.getY() > neighbourChunk.getMaxBuildHeight())
|
||||
if (relNeighbourBlockPos.getY() < neighbourChunk.getMinNonEmptyHeight() || relNeighbourBlockPos.getY() > neighbourChunk.getExclusiveMaxBuildHeight())
|
||||
{
|
||||
// the light pos is outside the chunk's min/max height,
|
||||
// this can happen if given a chunk that hasn't finished generating
|
||||
|
||||
@@ -23,18 +23,19 @@ import java.awt.*;
|
||||
|
||||
/**
|
||||
* Handles the bit-wise math used when
|
||||
* dealing with colors stored as integers.
|
||||
* dealing with colors stored as integers. <br><br>
|
||||
*
|
||||
* Minecraft color format is: 0xAA BB GG RR <br>
|
||||
* DH mod color format is: 0xAA RR GG BB <br>
|
||||
* OpenGL RGBA format native order: 0xRR GG BB AA <br>
|
||||
* OpenGL RGBA format Java Order: 0xAA BB GG RR <br>
|
||||
*
|
||||
* @author Cola
|
||||
* @author Leonardo Amato
|
||||
* @version 2023-5-15
|
||||
*/
|
||||
public class ColorUtil
|
||||
{
|
||||
//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
|
||||
|
||||
public static final int INVISIBLE = argbToInt(0, 0, 0, 0);
|
||||
|
||||
@@ -215,7 +216,7 @@ public class ColorUtil
|
||||
}
|
||||
|
||||
public static Color toColorObjRGB(int color) { return new Color(getRed(color), getGreen(color), getBlue(color)); }
|
||||
public static Color toColorObjRGBA(int color) { return new Color(getRed(color), getGreen(color), getBlue(color), getAlpha(color)); }
|
||||
public static Color toColorObjARGB(int color) { return new Color(getRed(color), getGreen(color), getBlue(color), getAlpha(color)); }
|
||||
|
||||
public static int toColorInt(Color color) { return argbToInt(color.getAlpha(), color.getRed(), color.getGreen(), color.getBlue()); }
|
||||
|
||||
|
||||
+4
-3
@@ -60,7 +60,7 @@ public class ChunkLightStorage
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public static ChunkLightStorage createSkyLightStorage(IChunkWrapper chunkWrapper) { return createSkyLightStorage(chunkWrapper.getMinBuildHeight(), chunkWrapper.getMaxBuildHeight()); }
|
||||
public static ChunkLightStorage createSkyLightStorage(IChunkWrapper chunkWrapper) { return createSkyLightStorage(chunkWrapper.getInclusiveMinBuildHeight(), chunkWrapper.getExclusiveMaxBuildHeight()); }
|
||||
public static ChunkLightStorage createSkyLightStorage(int minY, int maxY)
|
||||
{
|
||||
return new ChunkLightStorage(
|
||||
@@ -68,7 +68,7 @@ public class ChunkLightStorage
|
||||
// positions above should be lit but positions below should be unlit
|
||||
LodUtil.MAX_MC_LIGHT, LodUtil.MIN_MC_LIGHT);
|
||||
}
|
||||
public static ChunkLightStorage createBlockLightStorage(IChunkWrapper chunkWrapper) { return createBlockLightStorage(chunkWrapper.getMinBuildHeight(), chunkWrapper.getMaxBuildHeight()); }
|
||||
public static ChunkLightStorage createBlockLightStorage(IChunkWrapper chunkWrapper) { return createBlockLightStorage(chunkWrapper.getInclusiveMinBuildHeight(), chunkWrapper.getExclusiveMaxBuildHeight()); }
|
||||
public static ChunkLightStorage createBlockLightStorage(int minY, int maxY)
|
||||
{
|
||||
return new ChunkLightStorage(
|
||||
@@ -134,7 +134,8 @@ public class ChunkLightStorage
|
||||
//populate array if it doesn't exist.
|
||||
if (this.lightSections == null)
|
||||
{
|
||||
this.lightSections = new LightSection[BitShiftUtil.divideByPowerOfTwo(this.maxY - this.minY, 4)];
|
||||
int arrayLength = (this.maxY - this.minY) / 16;
|
||||
this.lightSections = new LightSection[arrayLength];
|
||||
}
|
||||
|
||||
int index = (y - this.minY) >> 4;
|
||||
|
||||
+12
-11
@@ -27,7 +27,6 @@ import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.sql.dto.BeaconBeamDTO;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IMutableBlockPosWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
@@ -47,18 +46,20 @@ public interface IChunkWrapper extends IBindable
|
||||
|
||||
DhChunkPos getChunkPos();
|
||||
|
||||
default int getHeight() { return this.getMaxBuildHeight() - this.getMinBuildHeight(); }
|
||||
int getMinBuildHeight();
|
||||
int getMaxBuildHeight();
|
||||
default int getHeight() { return this.getExclusiveMaxBuildHeight() - this.getInclusiveMinBuildHeight(); }
|
||||
/** inclusive (IE if returning -64 the min block can be placed at -64) */
|
||||
int getInclusiveMinBuildHeight();
|
||||
/** exclusive (IE if returning 320 the max block can be placed at 319) */
|
||||
int getExclusiveMaxBuildHeight();
|
||||
|
||||
/**
|
||||
* returns the Y level for the last non-empty section in this chunk,
|
||||
* or {@link IChunkWrapper#getMinBuildHeight()} if this chunk is completely empty.
|
||||
* or {@link IChunkWrapper#getInclusiveMinBuildHeight()} if this chunk is completely empty.
|
||||
*/
|
||||
int getMinNonEmptyHeight();
|
||||
/**
|
||||
* returns the Y level for the first non-empty section in this chunk,
|
||||
* or {@link IChunkWrapper#getMaxBuildHeight()} if this chunk is completely empty.
|
||||
* or {@link IChunkWrapper#getExclusiveMaxBuildHeight()} if this chunk is completely empty.
|
||||
*/
|
||||
int getMaxNonEmptyHeight();
|
||||
|
||||
@@ -99,7 +100,7 @@ public interface IChunkWrapper extends IBindable
|
||||
default boolean blockPosInsideChunk(int x, int y, int z)
|
||||
{
|
||||
return (x >= this.getMinBlockX() && x <= this.getMaxBlockX()
|
||||
&& y >= this.getMinBuildHeight() && y < this.getMaxBuildHeight()
|
||||
&& y >= this.getInclusiveMinBuildHeight() && y < this.getExclusiveMaxBuildHeight()
|
||||
&& z >= this.getMinBlockZ() && z <= this.getMaxBlockZ());
|
||||
}
|
||||
default boolean blockPosInsideChunk(DhBlockPos2D blockPos)
|
||||
@@ -144,8 +145,8 @@ public interface IChunkWrapper extends IBindable
|
||||
|
||||
|
||||
// FIXME +1 is to handle the fact that LodDataBuilder adds +1 to all block lighting calculations, also done in the constructor
|
||||
int minHeight = this.getMinBuildHeight();
|
||||
int maxHeight = this.getMaxBuildHeight() + 1;
|
||||
int minHeight = this.getInclusiveMinBuildHeight();
|
||||
int maxHeight = this.getExclusiveMaxBuildHeight() + 1;
|
||||
|
||||
if (x < 0 || x >= LodUtil.CHUNK_WIDTH
|
||||
|| z < 0 || z >= LodUtil.CHUNK_WIDTH
|
||||
@@ -167,7 +168,7 @@ public interface IChunkWrapper extends IBindable
|
||||
*/
|
||||
default int relativeBlockPosToIndex(int xRel, int y, int zRel)
|
||||
{
|
||||
int yRel = y - this.getMinBuildHeight();
|
||||
int yRel = y - this.getInclusiveMinBuildHeight();
|
||||
return (zRel * LodUtil.CHUNK_WIDTH * this.getHeight()) + (yRel * LodUtil.CHUNK_WIDTH) + xRel;
|
||||
}
|
||||
|
||||
@@ -183,7 +184,7 @@ public interface IChunkWrapper extends IBindable
|
||||
index -= (zRel * LodUtil.CHUNK_WIDTH * this.getHeight());
|
||||
|
||||
final int y = index / LodUtil.CHUNK_WIDTH;
|
||||
final int yRel = y + this.getMinBuildHeight();
|
||||
final int yRel = y + this.getInclusiveMinBuildHeight();
|
||||
|
||||
final int xRel = index % LodUtil.CHUNK_WIDTH;
|
||||
return new DhBlockPos(xRel, yRel, zRel);
|
||||
|
||||
Reference in New Issue
Block a user