Add IWrapperFactory and finish AbstractBlockPosWrapper

This commit is contained in:
James Seibel
2021-11-18 21:20:48 -06:00
parent 00058a22cf
commit e3fd2c4501
22 changed files with 128 additions and 83 deletions
@@ -57,9 +57,9 @@ import com.seibel.lod.core.util.LodThreadFactory;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.ThreadMapUtil;
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
/**
@@ -167,7 +167,7 @@ public class LodBufferBuilderFactory
* swapped with the drawable buffers in the LodRenderer to be drawn.
*/
public void generateLodBuffersAsync(LodRenderer renderer, LodDimension lodDim,
BlockPosWrapper playerBlockPos, boolean fullRegen)
AbstractBlockPosWrapper playerBlockPos, boolean fullRegen)
{
// only allow one generation process to happen at a time
@@ -190,7 +190,7 @@ public class LodBufferBuilderFactory
// more easily edited by hot swapping. Because, As far as James is aware
// you can't hot swap lambda expressions.
private void generateLodBuffersThread(LodRenderer renderer, LodDimension lodDim,
BlockPosWrapper playerBlockPos, boolean fullRegen)
AbstractBlockPosWrapper playerBlockPos, boolean fullRegen)
{
bufferLock.lock();
@@ -198,7 +198,7 @@ public class LodBufferBuilderFactory
{
// round the player's block position down to the nearest chunk BlockPos
ChunkPosWrapper playerChunkPos = new ChunkPosWrapper(playerBlockPos);
BlockPosWrapper playerBlockPosRounded = playerChunkPos.getWorldPosition();
AbstractBlockPosWrapper playerBlockPosRounded = playerChunkPos.getWorldPosition();
//long startTime = System.currentTimeMillis();
@@ -26,7 +26,7 @@ import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.objects.Box;
import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
import com.seibel.lod.core.util.ColorUtil;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
/**
* This is the abstract class used to create different
@@ -36,9 +36,8 @@ import com.seibel.lod.wrappers.block.BlockPosWrapper;
*/
public abstract class AbstractLodTemplate
{
/** Uploads the given LOD to the buffer. */
public abstract void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
public abstract void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled);
/** add the given position and color to the buffer */
@@ -28,7 +28,7 @@ import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
import com.seibel.lod.core.util.ColorUtil;
import com.seibel.lod.core.util.DataPointUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
/**
* Builds LODs as rectangular prisms.
@@ -44,7 +44,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
}
@Override
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
public void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled)
{
if (box == null)
@@ -79,7 +79,7 @@ public class CubicLodTemplate extends AbstractLodTemplate
private void generateBoundingBox(Box box,
int height, int depth, int width,
double xOffset, double yOffset, double zOffset,
BlockPosWrapper bufferCenterBlockPos,
AbstractBlockPosWrapper bufferCenterBlockPos,
Map<LodDirection, long[]> adjData,
int color,
int skyLight,
@@ -21,12 +21,12 @@ package com.seibel.lod.core.builders.bufferBuilding.lodTemplates;
import java.util.Map;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.api.lod.ClientApi;
import com.seibel.lod.core.enums.LodDirection;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.objects.Box;
import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
/**
* TODO DynamicLodTemplate
@@ -39,7 +39,7 @@ import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
public class DynamicLodTemplate extends AbstractLodTemplate
{
@Override
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
public void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled)
{
ClientApi.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
@@ -21,12 +21,12 @@ package com.seibel.lod.core.builders.bufferBuilding.lodTemplates;
import java.util.Map;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.api.lod.ClientApi;
import com.seibel.lod.core.enums.LodDirection;
import com.seibel.lod.core.enums.rendering.DebugMode;
import com.seibel.lod.core.objects.Box;
import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
/**
* TODO #21 TriangularLodTemplate
@@ -37,7 +37,7 @@ import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
public class TriangularLodTemplate extends AbstractLodTemplate
{
@Override
public void addLodToBuffer(LodBufferBuilder buffer, BlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
public void addLodToBuffer(LodBufferBuilder buffer, AbstractBlockPosWrapper bufferCenterBlockPos, long data, Map<LodDirection, long[]> adjData,
byte detailLevel, int posX, int posZ, Box box, DebugMode debugging, boolean[] adjShadeDisabled)
{
ClientApi.LOGGER.error(DynamicLodTemplate.class.getSimpleName() + " is not implemented!");
@@ -34,7 +34,9 @@ import com.seibel.lod.core.util.LevelPosUtil;
import com.seibel.lod.core.util.LodThreadFactory;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.ThreadMapUtil;
import com.seibel.lod.core.wrapperAdapters.IWrapperFactory;
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorSingletonWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockShapeWrapper;
@@ -44,9 +46,7 @@ import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IBiomeWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IDimensionTypeWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
/**
* This object is in charge of creating Lod related objects.
@@ -60,6 +60,7 @@ public class LodBuilder
{
private static final IMinecraftWrapper mc = SingletonHandler.get(IMinecraftWrapper.class);
private static final IBlockColorSingletonWrapper blockColorSingleton = SingletonHandler.get(IBlockColorSingletonWrapper.class);
private final IWrapperFactory wrapperFactory = SingletonHandler.get(IWrapperFactory.class);
private final ExecutorService lodGenThreadPool = Executors.newSingleThreadExecutor(new LodThreadFactory(this.getClass().getSimpleName()));
private final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
@@ -233,7 +234,7 @@ public class LodBuilder
boolean hasCeiling = mc.getWrappedClientWorld().getDimensionType().hasCeiling();
boolean hasSkyLight = mc.getWrappedClientWorld().getDimensionType().hasSkyLight();
boolean isDefault;
BlockPosWrapper blockPos = new BlockPosWrapper();
AbstractBlockPosWrapper blockPos = wrapperFactory.createBlockPos();
int index;
for (index = 0; index < size * size; index++)
@@ -294,7 +295,7 @@ public class LodBuilder
* Find the lowest valid point from the bottom.
* Used when creating a vertical LOD.
*/
private short determineBottomPointFrom(IChunkWrapper chunk, LodBuilderConfig config, int xAbs, int yAbs, int zAbs, BlockPosWrapper blockPos)
private short determineBottomPointFrom(IChunkWrapper chunk, LodBuilderConfig config, int xAbs, int yAbs, int zAbs, AbstractBlockPosWrapper blockPos)
{
short depth = DEFAULT_DEPTH;
@@ -311,7 +312,7 @@ public class LodBuilder
}
/** Find the highest valid point from the Top */
private short determineHeightPointFrom(IChunkWrapper chunk, LodBuilderConfig config, int xAbs, int yAbs, int zAbs, BlockPosWrapper blockPos)
private short determineHeightPointFrom(IChunkWrapper chunk, LodBuilderConfig config, int xAbs, int yAbs, int zAbs, AbstractBlockPosWrapper blockPos)
{
short height = DEFAULT_HEIGHT;
if (config.useHeightmap)
@@ -341,7 +342,7 @@ public class LodBuilder
* Generate the color for the given chunk using biome water color, foliage
* color, and grass color.
*/
private int generateLodColor(IChunkWrapper chunk, LodBuilderConfig builderConfig, int xRel, int yAbs, int zRel, BlockPosWrapper blockPos)
private int generateLodColor(IChunkWrapper chunk, LodBuilderConfig builderConfig, int xRel, int yAbs, int zRel, AbstractBlockPosWrapper blockPos)
{
int colorInt;
if (builderConfig.useBiomeColors)
@@ -379,7 +380,7 @@ public class LodBuilder
}
/** Gets the light value for the given block position */
private int getLightValue(IChunkWrapper chunk, BlockPosWrapper blockPos, boolean hasCeiling, boolean hasSkyLight, boolean topBlock)
private int getLightValue(IChunkWrapper chunk, AbstractBlockPosWrapper blockPos, boolean hasCeiling, boolean hasSkyLight, boolean topBlock)
{
int skyLight = 0;
int blockLight;
@@ -467,10 +468,8 @@ public class LodBuilder
}
/** Returns a color int for the given block. */
private int getColorForBlock(IChunkWrapper chunk, BlockPosWrapper blockPos)
private int getColorForBlock(IChunkWrapper chunk, AbstractBlockPosWrapper blockPos)
{
int colorOfBlock;
int colorInt;
@@ -516,10 +515,8 @@ public class LodBuilder
/** Is the block at the given blockPos a valid LOD point? */
private boolean isLayerValidLodPoint(IChunkWrapper chunk, BlockPosWrapper blockPos)
private boolean isLayerValidLodPoint(IChunkWrapper chunk, AbstractBlockPosWrapper blockPos)
{
if (chunk.isWaterLogged(blockPos))
return true;
@@ -30,10 +30,9 @@ import com.seibel.lod.core.util.ColorUtil;
import com.seibel.lod.core.util.DataPointUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
/**
* Similar to Minecraft's AxisAlignedBoundingBox.
@@ -311,7 +310,7 @@ public class Box
}
/** determine which faces should be culled */
public void setUpCulling(int cullingDistance, BlockPosWrapper playerPos)
public void setUpCulling(int cullingDistance, AbstractBlockPosWrapper playerPos)
{
for (LodDirection lodDirection : DIRECTIONS)
{
@@ -20,7 +20,7 @@
package com.seibel.lod.core.objects.lod;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
/**
@@ -54,7 +54,7 @@ public class RegionPos
}
/** Converts from a BlockPos to a RegionPos */
public RegionPos(BlockPosWrapper pos)
public RegionPos(AbstractBlockPosWrapper pos)
{
this(new ChunkPosWrapper(pos));
}
@@ -75,7 +75,7 @@ public class RegionPos
}
/** Returns the BlockPos at the center of this region */
public BlockPosWrapper blockPos()
public AbstractBlockPosWrapper blockPos()
{
return chunkPos().getWorldPosition()
.offset(LodUtil.CHUNK_WIDTH / 2, 0, LodUtil.CHUNK_WIDTH / 2);
@@ -45,9 +45,9 @@ import com.seibel.lod.core.util.DetailDistanceUtil;
import com.seibel.lod.core.util.LevelPosUtil;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
import com.seibel.lod.wrappers.handlers.ReflectionHandler;
import com.seibel.lod.wrappers.minecraft.MinecraftRenderWrapper;
@@ -547,7 +547,7 @@ public class LodRenderer
// translate the camera relative to the regions' center
// (AxisAlignedBoundingBoxes (LODs) use doubles and thus have a higher
// accuracy vs the model view matrix, which only uses floats)
BlockPosWrapper bufferPos = vbosCenter.getWorldPosition();
AbstractBlockPosWrapper bufferPos = vbosCenter.getWorldPosition();
double xDiff = projectedView.x - bufferPos.getX();
double zDiff = projectedView.z - bufferPos.getZ();
mcModelViewMatrix.multiplyTranslationMatrix(-xDiff, -projectedView.y, -zDiff);
@@ -32,11 +32,11 @@ import com.seibel.lod.core.objects.lod.RegionPos;
import com.seibel.lod.core.objects.opengl.DefaultLodVertexFormats;
import com.seibel.lod.core.objects.opengl.LodVertexFormat;
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IDimensionTypeWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
import com.seibel.lod.wrappers.minecraft.MinecraftRenderWrapper;
@@ -324,7 +324,7 @@ public class LodUtil
* Get a HashSet of all ChunkPos within the normal render distance
* that should not be rendered.
*/
public static HashSet<ChunkPosWrapper> getNearbyLodChunkPosToSkip(LodDimension lodDim, BlockPosWrapper blockPosWrapper)
public static HashSet<ChunkPosWrapper> getNearbyLodChunkPosToSkip(LodDimension lodDim, AbstractBlockPosWrapper blockPosWrapper)
{
int chunkRenderDist = MC_RENDER.getRenderDistance();
ChunkPosWrapper centerChunk = new ChunkPosWrapper(blockPosWrapper);
@@ -0,0 +1,14 @@
package com.seibel.lod.core.wrapperAdapters;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
/**
*
* @author James Seibel
* @version 11-18-2021
*/
public interface IWrapperFactory
{
public AbstractBlockPosWrapper createBlockPos();
public AbstractBlockPosWrapper createBlockPos(int x, int y, int z);
}
@@ -1,8 +1,8 @@
package com.seibel.lod.core.wrapperAdapters.chunk;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockShapeWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
import com.seibel.lod.wrappers.world.BiomeWrapper;
@@ -15,21 +15,21 @@ public interface IChunkWrapper
{
public int getHeight();
public boolean isPositionInWater(BlockPosWrapper blockPos);
public boolean isPositionInWater(AbstractBlockPosWrapper blockPos);
public int getHeightMapValue(int xRel, int zRel);
public BiomeWrapper getBiome(int xRel, int yAbs, int zRel);
public IBlockColorWrapper getBlockColorWrapper(BlockPosWrapper blockPos);
public IBlockColorWrapper getBlockColorWrapper(AbstractBlockPosWrapper blockPos);
public IBlockShapeWrapper getBlockShapeWrapper(BlockPosWrapper blockPos);
public IBlockShapeWrapper getBlockShapeWrapper(AbstractBlockPosWrapper blockPos);
public ChunkPosWrapper getPos();
public boolean isLightCorrect();
public boolean isWaterLogged(BlockPosWrapper blockPos);
public boolean isWaterLogged(AbstractBlockPosWrapper blockPos);
public int getEmittedBrightness(BlockPosWrapper blockPos);
public int getEmittedBrightness(AbstractBlockPosWrapper blockPos);
}
@@ -24,9 +24,9 @@ import java.io.File;
import java.util.ArrayList;
import com.seibel.lod.core.enums.LodDirection;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.misc.ILightMapWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
import com.seibel.lod.wrappers.world.DimensionTypeWrapper;
import com.seibel.lod.wrappers.world.WorldWrapper;
@@ -103,7 +103,7 @@ public interface IMinecraftWrapper
public boolean playerExists();
public BlockPosWrapper getPlayerBlockPos();
public AbstractBlockPosWrapper getPlayerBlockPos();
public ChunkPosWrapper getPlayerChunkPos();
@@ -19,7 +19,7 @@
package com.seibel.lod.core.wrapperAdapters.world;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.wrappers.world.WorldWrapper;
@@ -32,7 +32,7 @@ public interface IBiomeColorWrapperSingleton
{
public IBiomeColorWrapperSingleton getInstance();
public int getGrassColor(WorldWrapper world, BlockPosWrapper blockPos);
public int getWaterColor(WorldWrapper world, BlockPosWrapper blockPos);
public int getFoliageColor(WorldWrapper world, BlockPosWrapper blockPos);
public int getGrassColor(WorldWrapper world, AbstractBlockPosWrapper blockPos);
public int getWaterColor(WorldWrapper world, AbstractBlockPosWrapper blockPos);
public int getFoliageColor(WorldWrapper world, AbstractBlockPosWrapper blockPos);
}
@@ -2,7 +2,7 @@ package com.seibel.lod.core.wrapperAdapters.world;
import java.io.File;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
/**
*
@@ -14,11 +14,11 @@ public interface IWorldWrapper
{
public IDimensionTypeWrapper getDimensionType();
public int getBlockLight(BlockPosWrapper blockPos);
public int getBlockLight(AbstractBlockPosWrapper blockPos);
public int getSkyLight(BlockPosWrapper blockPos);
public int getSkyLight(AbstractBlockPosWrapper blockPos);
public IBiomeWrapper getBiome(BlockPosWrapper blockPos);
public IBiomeWrapper getBiome(AbstractBlockPosWrapper blockPos);
public boolean hasCeiling();
@@ -1,5 +1,6 @@
package com.seibel.lod.wrappers;
import com.seibel.lod.core.wrapperAdapters.IWrapperFactory;
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorSingletonWrapper;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
@@ -27,5 +28,6 @@ public class DependencySetup
SingletonHandler.bind(IBlockColorSingletonWrapper.class, BlockColorSingletonWrapper.INSTANCE);
SingletonHandler.bind(IMinecraftWrapper.class, MinecraftWrapper.INSTANCE);
SingletonHandler.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE);
SingletonHandler.bind(IWrapperFactory.class, WrapperFactory.INSTANCE);
}
}
@@ -0,0 +1,29 @@
package com.seibel.lod.wrappers;
import com.seibel.lod.core.wrapperAdapters.IWrapperFactory;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
/**
*
* @author James Seibel
* @version 11-18-2021
*/
public class WrapperFactory implements IWrapperFactory
{
public static final WrapperFactory INSTANCE = new WrapperFactory();
@Override
public AbstractBlockPosWrapper createBlockPos()
{
return new BlockPosWrapper();
}
@Override
public AbstractBlockPosWrapper createBlockPos(int x, int y, int z)
{
return new BlockPosWrapper(x,y,z);
}
}
@@ -5,6 +5,7 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockShapeWrapper;
import com.seibel.lod.core.wrapperAdapters.chunk.IChunkWrapper;
import com.seibel.lod.wrappers.chunk.ChunkWrapper;
@@ -31,13 +32,13 @@ public class BlockShapeWrapper implements IBlockShapeWrapper
private boolean noCollision;
/**Constructor only require for the block instance we are wrapping**/
public BlockShapeWrapper(Block block, IChunkWrapper chunkWrapper, BlockPosWrapper blockPosWrapper)
public BlockShapeWrapper(Block block, IChunkWrapper chunkWrapper, AbstractBlockPosWrapper blockPosWrapper)
{
this.block = block;
this.nonFull = false;
this.noCollision = false;
this.toAvoid = ofBlockToAvoid();
setupShapes((ChunkWrapper) chunkWrapper, blockPosWrapper);
setupShapes((ChunkWrapper) chunkWrapper, (BlockPosWrapper) blockPosWrapper);
//System.out.println(block + " non full " + nonFull + " no collision " + noCollision + " to avoid " + toAvoid);
}
@@ -53,7 +54,7 @@ public class BlockShapeWrapper implements IBlockShapeWrapper
* this return a wrapper of the block in input
* @param block Block object to wrap
*/
static public BlockShapeWrapper getBlockShapeWrapper(Block block, IChunkWrapper chunkWrapper, BlockPosWrapper blockPosWrapper)
static public BlockShapeWrapper getBlockShapeWrapper(Block block, IChunkWrapper chunkWrapper, AbstractBlockPosWrapper blockPosWrapper)
{
//first we check if the block has already been wrapped
if (blockShapeWrapperMap.containsKey(block) && blockShapeWrapperMap.get(block) != null)
@@ -1,12 +1,13 @@
package com.seibel.lod.wrappers.chunk;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import java.util.Objects;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
//This class wraps the minecraft ChunkPos class
public class ChunkPosWrapper
@@ -29,9 +30,9 @@ public class ChunkPosWrapper
this.chunkPos = newChunkPos.chunkPos;
}
public ChunkPosWrapper(BlockPosWrapper blockPos)
public ChunkPosWrapper(AbstractBlockPosWrapper blockPos)
{
this.chunkPos = new ChunkPos(blockPos.getBlockPos());
this.chunkPos = new ChunkPos(((BlockPosWrapper) blockPos).getBlockPos());
}
public ChunkPosWrapper(int chunkX, int chunkZ)
@@ -1,6 +1,7 @@
package com.seibel.lod.wrappers.chunk;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockShapeWrapper;
import com.seibel.lod.core.wrapperAdapters.chunk.IChunkWrapper;
@@ -32,9 +33,9 @@ public class ChunkWrapper implements IChunkWrapper
}
@Override
public boolean isPositionInWater(BlockPosWrapper blockPos)
public boolean isPositionInWater(AbstractBlockPosWrapper blockPos)
{
BlockState blockState = chunk.getBlockState(blockPos.getBlockPos());
BlockState blockState = chunk.getBlockState(((BlockPosWrapper) blockPos).getBlockPos());
//This type of block is always in water
return ((blockState.getBlock() instanceof ILiquidContainer) && !(blockState.getBlock() instanceof IWaterLoggable))
@@ -54,15 +55,15 @@ public class ChunkWrapper implements IChunkWrapper
}
@Override
public IBlockColorWrapper getBlockColorWrapper(BlockPosWrapper blockPos)
public IBlockColorWrapper getBlockColorWrapper(AbstractBlockPosWrapper blockPos)
{
return BlockColorWrapper.getBlockColorWrapper(chunk.getBlockState(blockPos.getBlockPos()).getBlock());
return BlockColorWrapper.getBlockColorWrapper(chunk.getBlockState(((BlockPosWrapper) blockPos).getBlockPos()).getBlock());
}
@Override
public IBlockShapeWrapper getBlockShapeWrapper(BlockPosWrapper blockPos)
public IBlockShapeWrapper getBlockShapeWrapper(AbstractBlockPosWrapper blockPos)
{
return BlockShapeWrapper.getBlockShapeWrapper(chunk.getBlockState(blockPos.getBlockPos()).getBlock(), this, blockPos);
return BlockShapeWrapper.getBlockShapeWrapper(chunk.getBlockState(((BlockPosWrapper) blockPos).getBlockPos()).getBlock(), this, blockPos);
}
public ChunkWrapper(IChunk chunk)
@@ -89,9 +90,9 @@ public class ChunkWrapper implements IChunkWrapper
}
@Override
public boolean isWaterLogged(BlockPosWrapper blockPos)
public boolean isWaterLogged(AbstractBlockPosWrapper blockPos)
{
BlockState blockState = chunk.getBlockState(blockPos.getBlockPos());
BlockState blockState = chunk.getBlockState(((BlockPosWrapper)blockPos).getBlockPos());
//This type of block is always in water
return ((blockState.getBlock() instanceof ILiquidContainer) && !(blockState.getBlock() instanceof IWaterLoggable))
@@ -99,8 +100,8 @@ public class ChunkWrapper implements IChunkWrapper
}
@Override
public int getEmittedBrightness(BlockPosWrapper blockPos)
public int getEmittedBrightness(AbstractBlockPosWrapper blockPos)
{
return chunk.getLightEmission(blockPos.getBlockPos());
return chunk.getLightEmission(((BlockPosWrapper)blockPos).getBlockPos());
}
}
@@ -19,6 +19,7 @@
package com.seibel.lod.wrappers.world;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IBiomeColorWrapperSingleton;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
@@ -42,18 +43,18 @@ public class BiomeColorWrapperSingleton implements IBiomeColorWrapperSingleton
@Override
public int getGrassColor(WorldWrapper world, BlockPosWrapper blockPos)
public int getGrassColor(WorldWrapper world, AbstractBlockPosWrapper blockPos)
{
return BiomeColors.getAverageGrassColor(world.getWorld(), blockPos.getBlockPos());
return BiomeColors.getAverageGrassColor(world.getWorld(), ((BlockPosWrapper) blockPos).getBlockPos());
}
@Override
public int getWaterColor(WorldWrapper world, BlockPosWrapper blockPos)
public int getWaterColor(WorldWrapper world, AbstractBlockPosWrapper blockPos)
{
return BiomeColors.getAverageWaterColor(world.getWorld(), blockPos.getBlockPos());
return BiomeColors.getAverageWaterColor(world.getWorld(), ((BlockPosWrapper) blockPos).getBlockPos());
}
@Override
public int getFoliageColor(WorldWrapper world, BlockPosWrapper blockPos)
public int getFoliageColor(WorldWrapper world, AbstractBlockPosWrapper blockPos)
{
return BiomeColors.getAverageFoliageColor(world.getWorld(), blockPos.getBlockPos());
return BiomeColors.getAverageFoliageColor(world.getWorld(), ((BlockPosWrapper) blockPos).getBlockPos());
}
}
@@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.seibel.lod.core.enums.WorldType;
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
import com.seibel.lod.wrappers.block.BlockPosWrapper;
@@ -67,21 +68,21 @@ public class WorldWrapper implements IWorldWrapper
}
@Override
public int getBlockLight(BlockPosWrapper blockPos)
public int getBlockLight(AbstractBlockPosWrapper blockPos)
{
return world.getLightEngine().blockEngine.getLightValue(blockPos.getBlockPos());
return world.getLightEngine().blockEngine.getLightValue(((BlockPosWrapper) blockPos).getBlockPos());
}
@Override
public int getSkyLight(BlockPosWrapper blockPos)
public int getSkyLight(AbstractBlockPosWrapper blockPos)
{
return world.getLightEngine().skyEngine.getLightValue(blockPos.getBlockPos());
return world.getLightEngine().skyEngine.getLightValue(((BlockPosWrapper) blockPos).getBlockPos());
}
@Override
public BiomeWrapper getBiome(BlockPosWrapper blockPos)
public BiomeWrapper getBiome(AbstractBlockPosWrapper blockPos)
{
return BiomeWrapper.getBiomeWrapper(world.getBiome(blockPos.getBlockPos()));
return BiomeWrapper.getBiomeWrapper(world.getBiome(((BlockPosWrapper) blockPos).getBlockPos()));
}
public IWorld getWorld()