Add IBlockColorSingletonWrapper
This commit is contained in:
@@ -35,11 +35,12 @@ import com.seibel.lod.core.util.LodThreadFactory;
|
|||||||
import com.seibel.lod.core.util.LodUtil;
|
import com.seibel.lod.core.util.LodUtil;
|
||||||
import com.seibel.lod.core.util.ThreadMapUtil;
|
import com.seibel.lod.core.util.ThreadMapUtil;
|
||||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||||
|
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorSingletonWrapper;
|
||||||
|
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
|
||||||
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
||||||
import com.seibel.lod.core.wrapperAdapters.world.IBiomeWrapper;
|
import com.seibel.lod.core.wrapperAdapters.world.IBiomeWrapper;
|
||||||
import com.seibel.lod.core.wrapperAdapters.world.IDimensionTypeWrapper;
|
import com.seibel.lod.core.wrapperAdapters.world.IDimensionTypeWrapper;
|
||||||
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
|
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
|
||||||
import com.seibel.lod.wrappers.block.BlockColorWrapper;
|
|
||||||
import com.seibel.lod.wrappers.block.BlockPosWrapper;
|
import com.seibel.lod.wrappers.block.BlockPosWrapper;
|
||||||
import com.seibel.lod.wrappers.block.BlockShapeWrapper;
|
import com.seibel.lod.wrappers.block.BlockShapeWrapper;
|
||||||
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
|
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
|
||||||
@@ -57,6 +58,7 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
|||||||
public class LodBuilder
|
public class LodBuilder
|
||||||
{
|
{
|
||||||
private static final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
private static final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||||
|
private static final IBlockColorSingletonWrapper blockColorSingleton = SingletonHandler.get(IBlockColorSingletonWrapper.class);
|
||||||
|
|
||||||
private final ExecutorService lodGenThreadPool = Executors.newSingleThreadExecutor(new LodThreadFactory(this.getClass().getSimpleName()));
|
private final ExecutorService lodGenThreadPool = Executors.newSingleThreadExecutor(new LodThreadFactory(this.getClass().getSimpleName()));
|
||||||
private final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
private final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||||
@@ -477,11 +479,11 @@ public class LodBuilder
|
|||||||
int y = blockPos.getY();
|
int y = blockPos.getY();
|
||||||
//int z = blockPos.getZ();
|
//int z = blockPos.getZ();
|
||||||
|
|
||||||
BlockColorWrapper blockColorWrapper;
|
IBlockColorWrapper blockColorWrapper;
|
||||||
BlockShapeWrapper blockShapeWrapper = chunk.getBlockShapeWrapper(blockPos);
|
BlockShapeWrapper blockShapeWrapper = chunk.getBlockShapeWrapper(blockPos);
|
||||||
|
|
||||||
if (chunk.isWaterLogged(blockPos))
|
if (chunk.isWaterLogged(blockPos))
|
||||||
blockColorWrapper = BlockColorWrapper.getWaterColor();
|
blockColorWrapper = blockColorSingleton.getWaterColor();
|
||||||
else
|
else
|
||||||
blockColorWrapper = chunk.getBlockColorWrapper(blockPos);
|
blockColorWrapper = chunk.getBlockColorWrapper(blockPos);
|
||||||
|
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package com.seibel.lod.core.wrapperAdapters.block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the static methods for IBlockColorWrapper
|
||||||
|
*
|
||||||
|
* @author James Seibel
|
||||||
|
* @version 11-17-2021
|
||||||
|
*/
|
||||||
|
public interface IBlockColorSingletonWrapper
|
||||||
|
{
|
||||||
|
/** returns the base color of water (grey value) */
|
||||||
|
public IBlockColorWrapper getWaterColor();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.seibel.lod.core.wrapperAdapters.block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class wraps the minecraft Block class
|
||||||
|
*
|
||||||
|
* @author James Seibel
|
||||||
|
* @version 11-17-2021
|
||||||
|
*/
|
||||||
|
public interface IBlockColorWrapper
|
||||||
|
{
|
||||||
|
//--------------//
|
||||||
|
//Colors getters//
|
||||||
|
//--------------//
|
||||||
|
|
||||||
|
public boolean hasColor();
|
||||||
|
|
||||||
|
public int getColor();
|
||||||
|
|
||||||
|
|
||||||
|
//------------//
|
||||||
|
//Tint getters//
|
||||||
|
//------------//
|
||||||
|
|
||||||
|
public boolean hasTint();
|
||||||
|
|
||||||
|
public boolean hasGrassTint();
|
||||||
|
|
||||||
|
public boolean hasFolliageTint();
|
||||||
|
|
||||||
|
public boolean hasWaterTint();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.seibel.lod.wrappers;
|
package com.seibel.lod.wrappers;
|
||||||
|
|
||||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||||
|
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorSingletonWrapper;
|
||||||
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
||||||
|
import com.seibel.lod.wrappers.block.BlockColorSingletonWrapper;
|
||||||
import com.seibel.lod.wrappers.config.LodConfigWrapperSingleton;
|
import com.seibel.lod.wrappers.config.LodConfigWrapperSingleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,5 +20,6 @@ public class DependencySetup
|
|||||||
public static void createInitialBindings()
|
public static void createInitialBindings()
|
||||||
{
|
{
|
||||||
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
|
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
|
||||||
|
SingletonHandler.bind(IBlockColorSingletonWrapper.class, BlockColorSingletonWrapper.INSTANCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.seibel.lod.wrappers.block;
|
||||||
|
|
||||||
|
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorSingletonWrapper;
|
||||||
|
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
|
||||||
|
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class wraps the minecraft Block class
|
||||||
|
*
|
||||||
|
* @author ??
|
||||||
|
* @version 11-17-2021
|
||||||
|
*/
|
||||||
|
public class BlockColorSingletonWrapper implements IBlockColorSingletonWrapper
|
||||||
|
{
|
||||||
|
public static final BlockColorSingletonWrapper INSTANCE = new BlockColorSingletonWrapper();
|
||||||
|
|
||||||
|
/** return base color of water (grey value) */
|
||||||
|
@Override
|
||||||
|
public IBlockColorWrapper getWaterColor()
|
||||||
|
{
|
||||||
|
return BlockColorWrapper.getBlockColorWrapper(Blocks.WATER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import com.seibel.lod.core.util.ColorUtil;
|
import com.seibel.lod.core.util.ColorUtil;
|
||||||
|
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
|
||||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractPlantBlock;
|
import net.minecraft.block.AbstractPlantBlock;
|
||||||
@@ -27,8 +28,13 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||||
|
|
||||||
|
|
||||||
//This class wraps the minecraft Block class
|
/**
|
||||||
public class BlockColorWrapper
|
* This class wraps the minecraft Block class
|
||||||
|
*
|
||||||
|
* @author ??
|
||||||
|
* @version 11-17-2021
|
||||||
|
*/
|
||||||
|
public class BlockColorWrapper implements IBlockColorWrapper
|
||||||
{
|
{
|
||||||
//set of block which require tint
|
//set of block which require tint
|
||||||
public static final ConcurrentMap<Block, BlockColorWrapper> blockColorWrapperMap = new ConcurrentHashMap<>();
|
public static final ConcurrentMap<Block, BlockColorWrapper> blockColorWrapperMap = new ConcurrentHashMap<>();
|
||||||
@@ -72,18 +78,11 @@ public class BlockColorWrapper
|
|||||||
//System.out.println(block + " color " + Integer.toHexString(color) + " to tint " + toTint + " folliageTint " + folliageTint + " grassTint " + grassTint + " waterTint " + waterTint);
|
//System.out.println(block + " color " + Integer.toHexString(color) + " to tint " + toTint + " folliageTint " + folliageTint + " grassTint " + grassTint + " waterTint " + waterTint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* return base color of water (grey value)
|
|
||||||
*/
|
|
||||||
static public BlockColorWrapper getWaterColor()
|
|
||||||
{
|
|
||||||
return getBlockColorWrapper(Blocks.WATER);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* this return a wrapper of the block in input
|
* this return a wrapper of the block in input
|
||||||
* @param block object of the block to wrap
|
* @param block object of the block to wrap
|
||||||
*/
|
*/
|
||||||
static public BlockColorWrapper getBlockColorWrapper(Block block)
|
public static IBlockColorWrapper getBlockColorWrapper(Block block)
|
||||||
{
|
{
|
||||||
//first we check if the block has already been wrapped
|
//first we check if the block has already been wrapped
|
||||||
if (blockColorWrapperMap.containsKey(block) && blockColorWrapperMap.get(block) != null)
|
if (blockColorWrapperMap.containsKey(block) && blockColorWrapperMap.get(block) != null)
|
||||||
@@ -253,11 +252,13 @@ public class BlockColorWrapper
|
|||||||
//Colors getters//
|
//Colors getters//
|
||||||
//--------------//
|
//--------------//
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasColor()
|
public boolean hasColor()
|
||||||
{
|
{
|
||||||
return isColored;
|
return isColored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getColor()
|
public int getColor()
|
||||||
{
|
{
|
||||||
return color;
|
return color;
|
||||||
@@ -268,21 +269,25 @@ public class BlockColorWrapper
|
|||||||
//------------//
|
//------------//
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasTint()
|
public boolean hasTint()
|
||||||
{
|
{
|
||||||
return toTint;
|
return toTint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasGrassTint()
|
public boolean hasGrassTint()
|
||||||
{
|
{
|
||||||
return grassTint;
|
return grassTint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasFolliageTint()
|
public boolean hasFolliageTint()
|
||||||
{
|
{
|
||||||
return foliageTint;
|
return foliageTint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasWaterTint()
|
public boolean hasWaterTint()
|
||||||
{
|
{
|
||||||
return waterTint;
|
return waterTint;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.seibel.lod.wrappers.chunk;
|
package com.seibel.lod.wrappers.chunk;
|
||||||
|
|
||||||
import com.seibel.lod.core.util.LodUtil;
|
import com.seibel.lod.core.util.LodUtil;
|
||||||
|
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
|
||||||
import com.seibel.lod.wrappers.block.BlockColorWrapper;
|
import com.seibel.lod.wrappers.block.BlockColorWrapper;
|
||||||
import com.seibel.lod.wrappers.block.BlockPosWrapper;
|
import com.seibel.lod.wrappers.block.BlockPosWrapper;
|
||||||
import com.seibel.lod.wrappers.block.BlockShapeWrapper;
|
import com.seibel.lod.wrappers.block.BlockShapeWrapper;
|
||||||
@@ -40,7 +41,7 @@ public class ChunkWrapper
|
|||||||
return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome(xRel >> 2, yAbs >> 2, zRel >> 2));
|
return BiomeWrapper.getBiomeWrapper(chunk.getBiomes().getNoiseBiome(xRel >> 2, yAbs >> 2, zRel >> 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockColorWrapper getBlockColorWrapper(BlockPosWrapper blockPos)
|
public IBlockColorWrapper getBlockColorWrapper(BlockPosWrapper blockPos)
|
||||||
{
|
{
|
||||||
return BlockColorWrapper.getBlockColorWrapper(chunk.getBlockState(blockPos.getBlockPos()).getBlock());
|
return BlockColorWrapper.getBlockColorWrapper(chunk.getBlockState(blockPos.getBlockPos()).getBlock());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
|
|
||||||
import com.seibel.lod.core.util.ColorUtil;
|
import com.seibel.lod.core.util.ColorUtil;
|
||||||
import com.seibel.lod.core.wrapperAdapters.world.IBiomeWrapper;
|
import com.seibel.lod.core.wrapperAdapters.world.IBiomeWrapper;
|
||||||
|
import com.seibel.lod.wrappers.block.BlockColorSingletonWrapper;
|
||||||
import com.seibel.lod.wrappers.block.BlockColorWrapper;
|
import com.seibel.lod.wrappers.block.BlockColorWrapper;
|
||||||
|
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
@@ -85,7 +86,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
|||||||
|
|
||||||
case OCEAN:
|
case OCEAN:
|
||||||
case RIVER:
|
case RIVER:
|
||||||
colorInt = BlockColorWrapper.getWaterColor().getColor();
|
colorInt = BlockColorSingletonWrapper.INSTANCE.getWaterColor().getColor();
|
||||||
tintValue = biome.getWaterColor();
|
tintValue = biome.getWaterColor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user