cleaned up some code
This commit is contained in:
@@ -387,24 +387,16 @@ public class LodBufferBuilder
|
||||
|
||||
//we get the above block as adj UP
|
||||
if (verticalIndex > 0)
|
||||
{
|
||||
adjData.get(Direction.UP)[0] = lodDim.getData(detailLevel, posX, posZ, verticalIndex - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
adjData.get(Direction.UP)[0] = DataPointUtil.EMPTY_DATA;
|
||||
}
|
||||
|
||||
|
||||
//we get the below block as adj DOWN
|
||||
if (verticalIndex < lodDim.getMaxVerticalData(detailLevel, posX, posZ) - 1)
|
||||
{
|
||||
adjData.get(Direction.DOWN)[0] = lodDim.getData(detailLevel, posX, posZ, verticalIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
adjData.get(Direction.DOWN)[0] = DataPointUtil.EMPTY_DATA;
|
||||
}
|
||||
|
||||
//We extract the data to render
|
||||
data = lodDim.getData(detailLevel, posX, posZ, verticalIndex);
|
||||
@@ -418,16 +410,13 @@ public class LodBufferBuilder
|
||||
detailLevel, posX, posZ, box, renderer.previousDebugMode, adjShadeDisabled);
|
||||
}
|
||||
|
||||
|
||||
} // for pos to in list to render
|
||||
// the thread executed successfully
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
nodeToRenderThreads.add(dataToRenderThread);
|
||||
|
||||
|
||||
}
|
||||
} // region z
|
||||
} // region z
|
||||
@@ -506,13 +495,11 @@ public class LodBufferBuilder
|
||||
|
||||
// get the positions that will be rendered
|
||||
|
||||
boolean vanillaRenderedPosition = gameChunkRenderDistance >= Math.abs(chunkXdist)
|
||||
&& gameChunkRenderDistance >= Math.abs(chunkZdist)
|
||||
&& detailLevel <= LodUtil.CHUNK_DETAIL_LEVEL
|
||||
&& vanillaRenderedChunks[chunkXdist + gameChunkRenderDistance + 1][chunkZdist + gameChunkRenderDistance + 1];
|
||||
|
||||
|
||||
return (vanillaRenderedPosition && (!(isItBorderPos)));
|
||||
return (gameChunkRenderDistance >= Math.abs(chunkXdist)
|
||||
&& gameChunkRenderDistance >= Math.abs(chunkZdist)
|
||||
&& detailLevel <= LodUtil.CHUNK_DETAIL_LEVEL
|
||||
&& vanillaRenderedChunks[chunkXdist + gameChunkRenderDistance + 1][chunkZdist + gameChunkRenderDistance + 1])
|
||||
&& (!isItBorderPos);
|
||||
}
|
||||
|
||||
|
||||
@@ -815,8 +802,7 @@ public class LodBufferBuilder
|
||||
}
|
||||
}
|
||||
|
||||
/** Uploads the uploadBuffer so the GPU can use it.
|
||||
* @param uploadMethod */
|
||||
/** Uploads the uploadBuffer so the GPU can use it. */
|
||||
private void vboUpload(VertexBuffer vbo, int storageBufferId, ByteBuffer uploadBuffer,
|
||||
boolean allowBufferExpansion, GpuUploadMethod uploadMethod)
|
||||
{
|
||||
@@ -888,7 +874,7 @@ public class LodBufferBuilder
|
||||
// in that case this will actually work better than SUB_DATA.
|
||||
|
||||
|
||||
ByteBuffer vboBuffer = null;
|
||||
ByteBuffer vboBuffer;
|
||||
|
||||
// map buffer range is better since it can be explicitly unsynchronized
|
||||
if (GlProxy.getInstance().mapBufferRangeSupported)
|
||||
|
||||
@@ -166,8 +166,6 @@ public class LodBuilder
|
||||
|
||||
int startX;
|
||||
int startZ;
|
||||
int endX;
|
||||
int endZ;
|
||||
|
||||
|
||||
LodRegion region = lodDim.getRegion(chunk.getPos().getRegionX(), chunk.getPos().getRegionZ());
|
||||
@@ -267,7 +265,7 @@ public class LodBuilder
|
||||
{
|
||||
yAbs = depth;
|
||||
blockPos.set(xAbs, yAbs, zAbs);
|
||||
light = getLightValue(chunk, blockPos, hasCeiling, hasSkyLight, topBlock);
|
||||
light = getLightValue(chunk, blockPos, true, hasSkyLight, true);
|
||||
color = generateLodColor(chunk, config, xAbs, yAbs, zAbs, blockPos);
|
||||
blockPos.set(xAbs, yAbs - 1, zAbs);
|
||||
}
|
||||
@@ -344,7 +342,7 @@ public class LodBuilder
|
||||
*/
|
||||
private int generateLodColor(ChunkWrapper chunk, LodBuilderConfig config, int xRel, int yAbs, int zRel, BlockPosWrapper blockPos)
|
||||
{
|
||||
int colorInt = 0;
|
||||
int colorInt;
|
||||
if (config.useBiomeColors)
|
||||
{
|
||||
// I have no idea why I need to bit shift to the right, but
|
||||
@@ -408,8 +406,8 @@ public class LodBuilder
|
||||
{
|
||||
if (hasSkyLight)
|
||||
skyLight = world.getSkyLight(blockPos);
|
||||
else
|
||||
skyLight = 0;
|
||||
//else
|
||||
// skyLight = 0;
|
||||
}
|
||||
if (!topBlock && skyLight == 15)
|
||||
{
|
||||
@@ -441,8 +439,8 @@ public class LodBuilder
|
||||
|
||||
if (hasSkyLight)
|
||||
skyLight = world.getSkyLight(blockPos);
|
||||
else
|
||||
skyLight = 0;
|
||||
//else
|
||||
// skyLight = 0;
|
||||
|
||||
if (!chunk.isLightCorrect() && (skyLight == 0 || skyLight == 15))
|
||||
{
|
||||
@@ -477,9 +475,9 @@ public class LodBuilder
|
||||
|
||||
int xRel = blockPos.getX() - chunk.getPos().getMinBlockX();
|
||||
int zRel = blockPos.getZ() - chunk.getPos().getMinBlockZ();
|
||||
int x = blockPos.getX();
|
||||
//int x = blockPos.getX();
|
||||
int y = blockPos.getY();
|
||||
int z = blockPos.getZ();
|
||||
//int z = blockPos.getZ();
|
||||
|
||||
BlockColorWrapper blockColorWrapper;
|
||||
BlockShapeWrapper blockShapeWrapper = chunk.getBlockShapeWrapper(blockPos);
|
||||
@@ -490,43 +488,31 @@ public class LodBuilder
|
||||
return biome.getWaterTint();
|
||||
}
|
||||
else
|
||||
{
|
||||
blockColorWrapper = chunk.getBlockColorWrapper(blockPos);
|
||||
}
|
||||
|
||||
if (blockShapeWrapper.isToAvoid())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
colorOfBlock = blockColorWrapper.getColor();
|
||||
|
||||
|
||||
if (blockColorWrapper.hasTint())
|
||||
{
|
||||
|
||||
WorldWrapper world = MinecraftWrapper.INSTANCE.getWrappedServerWorld();
|
||||
|
||||
if (world.isEmpty())
|
||||
{
|
||||
world = MinecraftWrapper.INSTANCE.getWrappedClientWorld();
|
||||
}
|
||||
|
||||
int tintValue;
|
||||
if (blockColorWrapper.hasGrassTint())
|
||||
{
|
||||
// grass and green plants
|
||||
tintValue = BiomeColorWrapper.getGrassColor(world, blockPos);
|
||||
}
|
||||
else if (blockColorWrapper.hasFolliageTint())
|
||||
{
|
||||
tintValue = BiomeColorWrapper.getFoliageColor(world, blockPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
//we can reintroduce this with the wrappers
|
||||
tintValue = BiomeColorWrapper.getWaterColor(world, blockPos);
|
||||
}
|
||||
|
||||
colorInt = ColorUtil.multiplyRGBcolors(tintValue | 0xFF000000, colorOfBlock);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -337,8 +337,6 @@ public class LodGenWorker implements IWorker
|
||||
heightmap.setHeight(x, z, seaLevel + 30);
|
||||
break;
|
||||
case MESA:
|
||||
heightmap.setHeight(x, z, seaLevel + 20);
|
||||
break;
|
||||
case JUNGLE:
|
||||
heightmap.setHeight(x, z, seaLevel + 20);
|
||||
break;
|
||||
@@ -514,7 +512,7 @@ public class LodGenWorker implements IWorker
|
||||
{
|
||||
configuredFeature.place(lodServerWorld, chunkGen, serverWorld.random, chunk.getPos().getWorldPosition());
|
||||
}
|
||||
catch (ConcurrentModificationException e)
|
||||
catch (ConcurrentModificationException | UnsupportedOperationException e)
|
||||
{
|
||||
// This will happen. I'm not sure what to do about it
|
||||
// except pray that it doesn't affect the normal world generation
|
||||
@@ -534,16 +532,9 @@ public class LodGenWorker implements IWorker
|
||||
configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature);
|
||||
// ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount());
|
||||
}
|
||||
catch (UnsupportedOperationException e)
|
||||
{
|
||||
// This will happen when the LodServerWorld
|
||||
// isn't able to return something that a feature
|
||||
// generator needs
|
||||
|
||||
if (!allowUnstableFeatures)
|
||||
configuredFeaturesToAvoid.put(configuredFeature.hashCode(), configuredFeature);
|
||||
// ClientProxy.LOGGER.info(configuredFeaturesToAvoid.mappingCount());
|
||||
}
|
||||
// This will happen when the LodServerWorld
|
||||
// isn't able to return something that a feature
|
||||
// generator needs
|
||||
catch (Exception e)
|
||||
{
|
||||
// I'm not sure what happened, print to the log
|
||||
|
||||
@@ -479,7 +479,7 @@ public class LodRegion
|
||||
posX = LevelPosUtil.getRegionModule(detailLevel, posX);
|
||||
posZ = LevelPosUtil.getRegionModule(detailLevel, posZ);
|
||||
|
||||
if (dataContainer == null || dataContainer[detailLevel] == null)
|
||||
if (dataContainer[detailLevel] == null)
|
||||
return false;
|
||||
|
||||
return dataContainer[detailLevel].doesItExist(posX, posZ);
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ClientProxy
|
||||
firstFrameSetup();
|
||||
|
||||
|
||||
if (mc == null || mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded())
|
||||
if (mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded())
|
||||
return;
|
||||
|
||||
LodDimension lodDim = lodWorld.getLodDimension(mc.getCurrentDimension());
|
||||
@@ -201,7 +201,7 @@ public class ClientProxy
|
||||
@SubscribeEvent
|
||||
public void serverTickEvent(TickEvent.ServerTickEvent event)
|
||||
{
|
||||
if (mc == null || mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded())
|
||||
if (mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded())
|
||||
return;
|
||||
|
||||
LodDimension lodDim = lodWorld.getLodDimension(mc.getPlayer().level.dimensionType());
|
||||
@@ -220,8 +220,7 @@ public class ClientProxy
|
||||
@SubscribeEvent
|
||||
public void worldSaveEvent(WorldEvent.Save event)
|
||||
{
|
||||
if (lodWorld != null)
|
||||
lodWorld.saveAllDimensions();
|
||||
lodWorld.saveAllDimensions();
|
||||
}
|
||||
|
||||
/** This is also called when a new dimension loads */
|
||||
|
||||
@@ -27,7 +27,7 @@ public class BlockColorWrapper
|
||||
//public static BlockColourWrapper WATER_COLOR = getBlockColorWrapper(Blocks.WATER);
|
||||
public static final Direction[] directions = new Direction[] { Direction.UP, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.DOWN };
|
||||
|
||||
private Block block;
|
||||
private final Block block;
|
||||
private int color;
|
||||
private boolean isColored;
|
||||
private boolean toTint;
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
|
||||
package com.seibel.lod.wrappers.Block;
|
||||
|
||||
import com.seibel.lod.util.ColorUtil;
|
||||
import com.seibel.lod.wrappers.Chunk.ChunkWrapper;
|
||||
import com.seibel.lod.wrappers.MinecraftWrapper;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.SixWayBlock;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
@@ -26,8 +22,8 @@ public class BlockShapeWrapper
|
||||
public static final ConcurrentMap<Block, BlockShapeWrapper> blockShapeWrapperMap = new ConcurrentHashMap<>();
|
||||
public static BlockShapeWrapper WATER_SHAPE = new BlockShapeWrapper();
|
||||
|
||||
private Block block;
|
||||
private boolean toAvoid;
|
||||
private final Block block;
|
||||
private final boolean toAvoid;
|
||||
private boolean nonFull;
|
||||
private boolean noCollision;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user