Cleanup and remove some MC references in Core

This commit is contained in:
James Seibel
2021-11-20 12:03:48 -06:00
parent 03aa4d3f17
commit f5e84005bb
12 changed files with 22 additions and 55 deletions
@@ -23,7 +23,6 @@ import com.seibel.lod.core.util.LevelPosUtil;
/** /**
* Holds the levelPos that need to be generated. * Holds the levelPos that need to be generated.
* TODO is that correct?
* *
* @author Leonardo Amato * @author Leonardo Amato
* @version 9-27-2021 * @version 9-27-2021
@@ -36,8 +36,6 @@ public class PosToRenderContainer
private int regionPosZ; private int regionPosZ;
private int numberOfPosToRender; private int numberOfPosToRender;
private int[] posToRender; private int[] posToRender;
/*TODO this population matrix could be converted to boolean to improve memory use
* no since bools are stored as bytes anyway - cola*/
private byte[][] population; private byte[][] population;
public PosToRenderContainer(byte minDetail, int regionPosX, int regionPosZ) public PosToRenderContainer(byte minDetail, int regionPosX, int regionPosZ)
@@ -21,8 +21,6 @@ package com.seibel.lod.core.objects.math;
import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.util.LodUtil;
import net.minecraft.util.math.vector.Vector3i;
/** /**
* A (almost) exact copy of Minecraft's 1.16.5 * A (almost) exact copy of Minecraft's 1.16.5
* implementation of a 3 element vector. * implementation of a 3 element vector.
@@ -153,11 +151,11 @@ public class Vec3i
return (xAdd * xAdd) + (yAdd * yAdd) + (zAdd * zAdd); return (xAdd * xAdd) + (yAdd * yAdd) + (zAdd * zAdd);
} }
public int distManhattan(Vector3i otherVec) public int distManhattan(Vec3i otherVec)
{ {
float xSub = Math.abs(otherVec.getX() - this.x); float xSub = Math.abs(otherVec.x - this.x);
float ySub = Math.abs(otherVec.getY() - this.y); float ySub = Math.abs(otherVec.y - this.y);
float zSub = Math.abs(otherVec.getZ() - this.z); float zSub = Math.abs(otherVec.z - this.z);
return (int) (xSub + ySub + zSub); return (int) (xSub + ySub + zSub);
} }
@@ -26,8 +26,6 @@ import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30; import org.lwjgl.opengl.GL30;
import org.lwjgl.opengl.GLCapabilities; import org.lwjgl.opengl.GLCapabilities;
import com.mojang.blaze3d.systems.IRenderCall;
import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.lod.api.lod.ClientApi; import com.seibel.lod.api.lod.ClientApi;
import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.enums.rendering.GlProxyContext; import com.seibel.lod.core.enums.rendering.GlProxyContext;
@@ -92,7 +90,7 @@ public class GlProxy
// getting Minecraft's context has to be done on the render thread, // getting Minecraft's context has to be done on the render thread,
// where the GL context is // where the GL context is
if (!RenderSystem.isOnRenderThread()) if (GLFW.glfwGetCurrentContext() == 0L)
throw new IllegalStateException(GlProxy.class.getSimpleName() + " was created outside the render thread!"); throw new IllegalStateException(GlProxy.class.getSimpleName() + " was created outside the render thread!");
@@ -285,7 +283,7 @@ public class GlProxy
* Useful for creating/destroying OpenGL objects in a thread * Useful for creating/destroying OpenGL objects in a thread
* that doesn't normally have access to a OpenGL context. * that doesn't normally have access to a OpenGL context.
*/ */
public void recordOpenGlCall(IRenderCall renderCall) //(Runnable renderCall) public void recordOpenGlCall(Runnable renderCall) //(Runnable renderCall)
{ {
// TODO this shouldn't rely on Minecraft's RenderSystem and should just run // TODO this shouldn't rely on Minecraft's RenderSystem and should just run
// on a executer thread with a separate context // on a executer thread with a separate context
@@ -83,7 +83,6 @@ public class LodRenderer
*/ */
public DebugMode previousDebugMode = DebugMode.OFF; public DebugMode previousDebugMode = DebugMode.OFF;
private IProfiler profiler;
private int farPlaneBlockDistance; private int farPlaneBlockDistance;
@@ -156,7 +155,7 @@ public class LodRenderer
* @param mcProjectionMatrix * @param mcProjectionMatrix
* @param partialTicks how far into the current tick this method was called. * @param partialTicks how far into the current tick this method was called.
*/ */
public void drawLODs(LodDimension lodDim, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, IProfiler newProfiler) public void drawLODs(LodDimension lodDim, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, IProfiler profiler)
{ {
//=================================// //=================================//
// determine if LODs should render // // determine if LODs should render //
@@ -221,7 +220,6 @@ public class LodRenderer
// initial setup // // initial setup //
//===============// //===============//
profiler = newProfiler;
profiler.push("LOD setup"); profiler.push("LOD setup");
GlProxy glProxy = GlProxy.getInstance(); GlProxy glProxy = GlProxy.getInstance();
@@ -24,9 +24,7 @@ import com.seibel.lod.core.enums.config.HorizontalQuality;
import com.seibel.lod.core.enums.config.HorizontalResolution; import com.seibel.lod.core.enums.config.HorizontalResolution;
import com.seibel.lod.core.wrapperAdapters.SingletonHandler; import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
import com.seibel.lod.wrappers.minecraft.MinecraftRenderWrapper; import com.seibel.lod.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
/** /**
* *
@@ -36,7 +34,6 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
public class DetailDistanceUtil public class DetailDistanceUtil
{ {
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IMinecraftWrapper MC = SingletonHandler.get(IMinecraftWrapper.class);
private static final MinecraftRenderWrapper MC_RENDER = MinecraftRenderWrapper.INSTANCE; private static final MinecraftRenderWrapper MC_RENDER = MinecraftRenderWrapper.INSTANCE;
private static final double genMultiplier = 1.0; private static final double genMultiplier = 1.0;
@@ -41,10 +41,6 @@ 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.minecraft.MinecraftRenderWrapper; import com.seibel.lod.wrappers.minecraft.MinecraftRenderWrapper;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.Heightmap;
/** /**
* This class holds methods and constants that may be used in multiple places. * This class holds methods and constants that may be used in multiple places.
* *
@@ -125,11 +121,6 @@ public class LodUtil
public static final int REGION_WIDTH_IN_CHUNKS = REGION_WIDTH / CHUNK_WIDTH; public static final int REGION_WIDTH_IN_CHUNKS = REGION_WIDTH / CHUNK_WIDTH;
/**
* If we ever need to use a heightmap for any reason, use this one.
*/
public static final Heightmap.Type DEFAULT_HEIGHTMAP = Heightmap.Type.WORLD_SURFACE_WG;
/** /**
* This regex finds any characters that are invalid for use in a windows * This regex finds any characters that are invalid for use in a windows
* (and by extension mac and linux) file path * (and by extension mac and linux) file path
@@ -195,23 +186,6 @@ public class LodUtil
return pos / (1 << (targetDetailLevel - currentDetailLevel)); return pos / (1 << (targetDetailLevel - currentDetailLevel));
} }
/**
* Return whether the given chunk
* has any data in it.
*/
public static boolean chunkHasBlockData(IChunk chunk)
{
ChunkSection[] blockStorage = chunk.getSections();
for (ChunkSection section : blockStorage)
{
if (section != null && !section.isEmpty())
return true;
}
return false;
}
/** /**
* If on single player this will return the name of the user's * If on single player this will return the name of the user's
@@ -6,7 +6,6 @@ import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
/** /**
* *
* @author James Seibel
* @author ?? * @author ??
* @version 11-15-2021 * @version 11-15-2021
*/ */
@@ -0,0 +1,9 @@
package com.seibel.lod.wrappers;
public class WrapperUtil
{
/** If we ever need to use a heightmap for any reason, use this one. */
public static final Heightmap.Type DEFAULT_HEIGHTMAP = Heightmap.Type.WORLD_SURFACE_WG;
}
@@ -1,10 +1,10 @@
package com.seibel.lod.wrappers.chunk; 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.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper; import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
import com.seibel.lod.core.wrapperAdapters.block.IBlockShapeWrapper; import com.seibel.lod.core.wrapperAdapters.block.IBlockShapeWrapper;
import com.seibel.lod.core.wrapperAdapters.chunk.IChunkWrapper; import com.seibel.lod.core.wrapperAdapters.chunk.IChunkWrapper;
import com.seibel.lod.wrappers.WrapperUtil;
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;
@@ -45,7 +45,7 @@ public class ChunkWrapper implements IChunkWrapper
@Override @Override
public int getHeightMapValue(int xRel, int zRel) public int getHeightMapValue(int xRel, int zRel)
{ {
return chunk.getOrCreateHeightmapUnprimed(LodUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel); return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel);
} }
@Override @Override
@@ -26,16 +26,14 @@ import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.wrappers.WrapperUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
import net.minecraft.particles.IParticleData; import net.minecraft.particles.IParticleData;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@@ -54,7 +52,6 @@ import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk; import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.Heightmap; import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.gen.Heightmap.Type;
import net.minecraft.world.gen.feature.structure.Structure; import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.feature.structure.StructureStart; import net.minecraft.world.gen.feature.structure.StructureStart;
import net.minecraft.world.lighting.WorldLightManager; import net.minecraft.world.lighting.WorldLightManager;
@@ -97,7 +94,7 @@ public class LodServerWorld implements ISeedReader
z = z % LodUtil.CHUNK_WIDTH; z = z % LodUtil.CHUNK_WIDTH;
z = (z < 0) ? z + 16 : z; z = (z < 0) ? z + 16 : z;
return chunk.getOrCreateHeightmapUnprimed(LodUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(x, z); return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(x, z);
} }
@Override @Override
@@ -17,12 +17,12 @@ import com.seibel.lod.core.wrapperAdapters.chunk.AbstractChunkPosWrapper;
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton; import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper; import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
import com.seibel.lod.core.wrapperAdapters.worldGeneration.AbstractWorldGeneratorWrapper; import com.seibel.lod.core.wrapperAdapters.worldGeneration.AbstractWorldGeneratorWrapper;
import com.seibel.lod.wrappers.WrapperUtil;
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper; import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
import com.seibel.lod.wrappers.chunk.ChunkWrapper; import com.seibel.lod.wrappers.chunk.ChunkWrapper;
import com.seibel.lod.wrappers.world.WorldWrapper; import com.seibel.lod.wrappers.world.WorldWrapper;
import net.minecraft.util.palette.UpgradeData; import net.minecraft.util.palette.UpgradeData;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
@@ -103,7 +103,7 @@ public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper
boolean inTheEnd = false; boolean inTheEnd = false;
// add fake heightmap data so our LODs aren't at height 0 // add fake heightmap data so our LODs aren't at height 0
Heightmap heightmap = new Heightmap(chunk, LodUtil.DEFAULT_HEIGHTMAP); Heightmap heightmap = new Heightmap(chunk, WrapperUtil.DEFAULT_HEIGHTMAP);
for (int x = 0; x < LodUtil.CHUNK_WIDTH && !inTheEnd; x++) for (int x = 0; x < LodUtil.CHUNK_WIDTH && !inTheEnd; x++)
{ {
for (int z = 0; z < LodUtil.CHUNK_WIDTH && !inTheEnd; z++) for (int z = 0; z < LodUtil.CHUNK_WIDTH && !inTheEnd; z++)