Continue porting process

This commit is contained in:
James Seibel
2021-10-29 23:32:49 -05:00
parent 58ad37c056
commit 991b3356bb
20 changed files with 238 additions and 206 deletions
@@ -21,13 +21,10 @@ package com.seibel.lod.builders.bufferBuilding;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.locks.ReentrantLock;
import org.lwjgl.opengl.GL11;
@@ -37,6 +34,8 @@ import org.lwjgl.opengl.GL45;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.VertexBuffer;
import com.seibel.lod.builders.bufferBuilding.lodTemplates.Box;
import com.seibel.lod.config.LodConfig;
import com.seibel.lod.enums.GlProxyContext;
@@ -57,13 +56,10 @@ import com.seibel.lod.util.LodUtil;
import com.seibel.lod.util.ThreadMapUtil;
import com.seibel.lod.wrappers.MinecraftWrapper;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.vertex.VertexBuffer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.LightType;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.ChunkPos;
/**
* This object is used to create NearFarBuffer objects.
@@ -232,7 +228,7 @@ public class LodBufferBuilder
// create the nodeToRenderThreads //
//================================//
ClientWorld world = mc.getClientWorld();
ClientLevel world = mc.getClientLevel();
skyLightPlayer = world.getBrightness(LightType.SKY, playerBlockPos);
for (int xRegion = 0; xRegion < lodDim.getWidth(); xRegion++)
@@ -30,9 +30,9 @@ import com.seibel.lod.util.DataPointUtil;
import com.seibel.lod.util.LodUtil;
import com.seibel.lod.wrappers.MinecraftWrapper;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
/**
* Similar to Minecraft's AxisAlignedBoundingBox.
@@ -125,7 +125,7 @@ public class Box
* This is a map from Direction to the relative normal vector
* we are using this since I'm not sure if the getNormal create new object at every call
*/
public static final Map<Direction, Vector3i> DIRECTION_NORMAL_MAP = new HashMap<Direction, Vector3i>()
public static final Map<Direction, Vec3i> DIRECTION_NORMAL_MAP = new HashMap<Direction, Vec3i>()
{{
put(Direction.UP, Direction.UP.getNormal());
put(Direction.DOWN, Direction.DOWN.getNormal());
@@ -226,7 +226,7 @@ public class Box
for (Direction direction : DIRECTIONS)
{
if (!adjShadeDisabled[DIRECTION_INDEX.get(direction)])
colorMap[DIRECTION_INDEX.get(direction)] = ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getClientWorld().getShade(direction, true));
colorMap[DIRECTION_INDEX.get(direction)] = ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getClientLevel().getShade(direction, true));
else
colorMap[DIRECTION_INDEX.get(direction)] = color;
}
@@ -241,7 +241,7 @@ public class Box
if (LodConfig.CLIENT.advancedModOptions.debugging.debugMode.get() != DebugMode.SHOW_DETAIL)
return colorMap[DIRECTION_INDEX.get(direction)];
else
return ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getClientWorld().getShade(direction, true));
return ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getClientLevel().getShade(direction, true));
}
/**
@@ -111,7 +111,7 @@ public class LodBuilder
{
// we need a loaded client world in order to
// get the textures for blocks
if (mc.getClientWorld() == null)
if (mc.getClientLevel() == null)
return;
// don't try to generate LODs if the user isn't in the world anymore
@@ -231,8 +231,8 @@ public class LodBuilder
int xAbs;
int yAbs;
int zAbs;
boolean hasCeiling = mc.getClientWorld().dimensionType().hasCeiling();
boolean hasSkyLight = mc.getClientWorld().dimensionType().hasSkyLight();
boolean hasCeiling = mc.getClientLevel().dimensionType().hasCeiling();
boolean hasSkyLight = mc.getClientLevel().dimensionType().hasSkyLight();
boolean isDefault;
BlockPosWrapper blockPos = new BlockPosWrapper();
int index;
@@ -415,7 +415,7 @@ public class LodBuilder
{
// we are on predicted terrain, and we don't know what the light here is,
// lets just take a guess
if (blockPos.getY() >= mc.getClientWorld().getSeaLevel() - 5)
if (blockPos.getY() >= mc.getClientLevel().getSeaLevel() - 5)
{
skyLight = 12;
isDefault = 1;
@@ -426,7 +426,7 @@ public class LodBuilder
}
else
{
world = MinecraftWrapper.INSTANCE.getWrappedClientWorld();
world = MinecraftWrapper.INSTANCE.getWrappedClientLevel();
if (world.isEmpty())
return 0;
// client world sky light (almost never accurate)
@@ -448,7 +448,7 @@ public class LodBuilder
{
// we don't know what the light here is,
// lets just take a guess
if (blockPos.getY() >= mc.getClientWorld().getSeaLevel() - 5)
if (blockPos.getY() >= mc.getClientLevel().getSeaLevel() - 5)
{
skyLight = 12;
isDefault = 1;
@@ -509,7 +509,7 @@ public class LodBuilder
if (world.isEmpty())
{
world = MinecraftWrapper.INSTANCE.getWrappedClientWorld();
world = MinecraftWrapper.INSTANCE.getWrappedClientLevel();
}
int tintValue;
@@ -575,15 +575,8 @@ public class LodConfig
}
@SubscribeEvent
public static void onLoad(final ModConfig.Loading configEvent)
public static void onChange(final ModConfig configEvent)
{
LogManager.getLogger().debug(ModInfo.NAME, "Loaded forge config file {}", configEvent.getConfig().getFileName());
LogManager.getLogger().debug(ModInfo.NAME, "forge config file {} changed.", configEvent.getFileName());
}
@SubscribeEvent
public static void onFileChange(final ModConfig.Reloading configEvent)
{
LogManager.getLogger().debug(ModInfo.NAME, "Forge config just got changed on the file system!");
}
}
@@ -24,11 +24,11 @@ import java.io.File;
import com.seibel.lod.util.LodUtil;
import com.seibel.lod.wrappers.MinecraftWrapper;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.chunk.storage.ChunkSerializer;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.storage.ChunkSerializer;
/**
*
@@ -37,18 +37,18 @@ import net.minecraft.world.server.ServerWorld;
*/
public class ChunkLoader
{
public static IChunk getChunkFromFile(ChunkPos pos){
public static ChunkAccess getChunkFromFile(ChunkPos pos){
ClientWorld clientWorld = MinecraftWrapper.INSTANCE.getClientWorld();
if (clientWorld == null)
ClientLevel ClientLevel = MinecraftWrapper.INSTANCE.getClientLevel();
if (ClientLevel == null)
return null;
ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(clientWorld.dimensionType());
ServerLevel serverWorld = LodUtil.getServerLevelFromDimension(ClientLevel.dimensionType());
try
{
File file = new File(serverWorld.getChunkSource().getDataStorage().dataFolder.getParent() + File.separatorChar + "region", "r." + (pos.x >> 5) + "." + (pos.z >> 5) + ".mca");
if(!file.exists())
return null;
IChunk loadedChunk = ChunkSerializer.read(
ChunkAccess loadedChunk = ChunkSerializer.read(
serverWorld,
serverWorld.getStructureManager(),
serverWorld.getPoiManager(),
@@ -61,6 +61,10 @@ public class MixinWorldRenderer
// only render if LODs are enabled and
// only render before solid blocks
if (LodConfig.CLIENT.advancedModOptions.debugging.drawLods.get() && renderType.equals(RenderType.solid()))
LodMain.client_proxy.renderLods(modelViewMatrixStack, previousPartialTicks);
LodMain.client_proxy.renderLods(modelViewMatrixStack, projectionMatrix, previousPartialTicks);
}
}
@@ -36,10 +36,10 @@ import com.seibel.lod.util.LodThreadFactory;
import com.seibel.lod.util.LodUtil;
import com.seibel.lod.wrappers.MinecraftWrapper;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.server.ServerChunkProvider;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.dimension.DimensionType;
/**
@@ -113,11 +113,11 @@ public class LodDimension
{
// local world
ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(newDimension);
ServerLevel serverWorld = LodUtil.getServerLevelFromDimension(newDimension);
// provider needs a separate variable to prevent
// the compiler from complaining
ServerChunkProvider provider = serverWorld.getChunkSource();
ServerChunkCache provider = serverWorld.getChunkSource();
saveDir = new File(provider.dataStorage.dataFolder.getCanonicalFile().getPath() + File.separatorChar + "lod");
}
else
@@ -23,8 +23,9 @@ import java.util.Hashtable;
import java.util.Map;
import com.seibel.lod.proxy.ClientProxy;
import com.seibel.lod.wrappers.World.DimensionTypeWrapper;
import net.minecraft.world.DimensionType;
import net.minecraft.world.level.dimension.DimensionType;
/**
* This stores all LODs for a given world.
@@ -39,7 +40,7 @@ public class LodWorld
private String worldName;
/** dimensions in this world */
private Map<DimensionType, LodDimension> lodDimensions;
private Map<DimensionTypeWrapper, LodDimension> lodDimensions;
/** If true then the LOD world is setup and ready to use */
private boolean isWorldLoaded = false;
@@ -107,7 +108,7 @@ public class LodWorld
if (lodDimensions == null)
return;
lodDimensions.put(newDimension.dimension, newDimension);
lodDimensions.put(DimensionTypeWrapper.getDimensionTypeWrapper(newDimension.dimension), newDimension);
}
/**
@@ -132,7 +133,7 @@ public class LodWorld
saveAllDimensions();
for (DimensionType key : lodDimensions.keySet())
for (DimensionTypeWrapper key : lodDimensions.keySet())
lodDimensions.get(key).setRegionWidth(newRegionWidth);
}
@@ -148,7 +149,7 @@ public class LodWorld
// but that requires a LodDimension.hasDirtyRegions() method or something similar
ClientProxy.LOGGER.info("Saving LODs");
for (DimensionType key : lodDimensions.keySet())
for (DimensionTypeWrapper key : lodDimensions.keySet())
lodDimensions.get(key).saveDirtyRegionsToFileAsync();
}
@@ -20,9 +20,8 @@
package com.seibel.lod.objects;
import com.seibel.lod.util.LodUtil;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
/**
* This object is similar to ChunkPos or BlockPos.
@@ -55,28 +54,28 @@ public class RegionPos
}
/** Converts from a BlockPos to a RegionPos */
public RegionPos(BlockPos pos)
public RegionPos(BlockPosWrapper pos)
{
this(new ChunkPos(pos));
this(new ChunkPosWrapper(pos));
}
/** Converts from a ChunkPos to a RegionPos */
public RegionPos(ChunkPos pos)
public RegionPos(ChunkPosWrapper pos)
{
x = Math.floorDiv(pos.x, LodUtil.REGION_WIDTH_IN_CHUNKS);
z = Math.floorDiv(pos.z, LodUtil.REGION_WIDTH_IN_CHUNKS);
x = Math.floorDiv(pos.getX(), LodUtil.REGION_WIDTH_IN_CHUNKS);
z = Math.floorDiv(pos.getZ(), LodUtil.REGION_WIDTH_IN_CHUNKS);
}
/** Returns the ChunkPos at the center of this region */
public ChunkPos chunkPos()
public ChunkPosWrapper chunkPos()
{
return new ChunkPos(
return new ChunkPosWrapper(
(x * LodUtil.REGION_WIDTH_IN_CHUNKS) + LodUtil.REGION_WIDTH_IN_CHUNKS / 2,
(z * LodUtil.REGION_WIDTH_IN_CHUNKS) + LodUtil.REGION_WIDTH_IN_CHUNKS / 2);
}
/** Returns the BlockPos at the center of this region */
public BlockPos blockPos()
public ChunkPosWrapper blockPos()
{
return chunkPos().getWorldPosition()
.offset(LodUtil.CHUNK_WIDTH / 2, 0, LodUtil.CHUNK_WIDTH / 2);
@@ -19,12 +19,12 @@
package com.seibel.lod.proxy;
import com.seibel.lod.wrappers.Chunk.ChunkWrapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder;
import com.seibel.lod.builders.lodBuilding.LodBuilder;
import com.seibel.lod.builders.worldGeneration.LodGenWorker;
@@ -40,9 +40,10 @@ import com.seibel.lod.util.DetailDistanceUtil;
import com.seibel.lod.util.LodUtil;
import com.seibel.lod.util.ThreadMapUtil;
import com.seibel.lod.wrappers.MinecraftWrapper;
import com.seibel.lod.wrappers.Chunk.ChunkWrapper;
import net.minecraft.profiler.IProfiler;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.world.BlockEvent;
@@ -99,7 +100,7 @@ public class ClientProxy
//==============//
/** Do any setup that is required to draw LODs and then tell the LodRenderer to draw. */
public void renderLods(MatrixStack mcMatrixStack, float partialTicks)
public void renderLods(PoseStack mcModelViewMatrix, Matrix4f projectionMatrix, float partialTicks)
{
// comment out when creating a release
// applyConfigOverrides();
@@ -133,11 +134,11 @@ public class ClientProxy
// if "unspecified" shows up in the pie chart, it is
// possibly because the amount of time between sections
// is too small for the profiler to measure
IProfiler profiler = mc.getProfiler();
ProfilerFiller profiler = mc.getProfiler();
profiler.pop(); // get out of "terrain"
profiler.push("LOD");
renderer.drawLODs(lodDim, mcMatrixStack, partialTicks, mc.getProfiler());
renderer.drawLODs(lodDim, mcModelViewMatrix, partialTicks, mc.getProfiler());
profiler.pop(); // end LOD
profiler.push("terrain"); // go back into "terrain"
@@ -161,10 +162,10 @@ public class ClientProxy
// remind the developer(s) that the config override is active
if (!configOverrideReminderPrinted)
{
// mc.getPlayer().sendMessage(new StringTextComponent("LOD experimental build 1.5.1"), mc.getPlayer().getUUID());
// mc.getPlayer().sendMessage(new StringTextComponent("Here be dragons!"), mc.getPlayer().getUUID());
// mc.getPlayer().sendMessage(new TextComponent("LOD experimental build 1.5.1"), mc.getPlayer().getUUID());
// mc.getPlayer().sendMessage(new TextComponent("Here be dragons!"), mc.getPlayer().getUUID());
mc.getPlayer().sendMessage(new StringTextComponent("Debug settings enabled!"), mc.getPlayer().getUUID());
mc.getPlayer().sendMessage(new TextComponent("Debug settings enabled!"), mc.getPlayer().getUUID());
configOverrideReminderPrinted = true;
}
@@ -331,7 +332,7 @@ public class ClientProxy
{
// calculate how wide the dimension(s) should be in regions
int chunksWide;
if (mc.getClientWorld().dimensionType().hasCeiling())
if (mc.getClientLevel().dimensionType().hasCeiling())
chunksWide = Math.min(LodConfig.CLIENT.graphics.qualityOption.lodChunkRenderDistance.get(), LodUtil.CEILED_DIMENSION_MAX_RENDER_DISTANCE) * 2 + 1;
else
chunksWide = LodConfig.CLIENT.graphics.qualityOption.lodChunkRenderDistance.get() * 2 + 1;
@@ -348,7 +349,7 @@ public class ClientProxy
// update the dimensions to fit the new width
lodWorld.resizeDimensionRegionWidth(newWidth);
lodBuilder.defaultDimensionWidthInRegions = newWidth;
renderer.setupBuffers(lodWorld.getLodDimension(mc.getClientWorld().dimensionType()));
renderer.setupBuffers(lodWorld.getLodDimension(mc.getClientLevel().dimensionType()));
recalculateWidths = false;
//LOGGER.info("new dimension width in regions: " + newWidth + "\t potential: " + newWidth );
@@ -259,7 +259,7 @@ public class LodRenderer
Matrix4f modelViewMatrix = offsetTheModelViewMatrix(mcMatrixStack, partialTicks);
vanillaBlockRenderedDistance = mc.getRenderDistance() * LodUtil.CHUNK_WIDTH;
// required for setupFog and setupProjectionMatrix
if (mc.getClientWorld().dimensionType().hasCeiling())
if (mc.getClientLevel().dimensionType().hasCeiling())
farPlaneBlockDistance = Math.min(LodConfig.CLIENT.graphics.qualityOption.lodChunkRenderDistance.get(), LodUtil.CEILED_DIMENSION_MAX_RENDER_DISTANCE) * LodUtil.CHUNK_WIDTH;
else
farPlaneBlockDistance = LodConfig.CLIENT.graphics.qualityOption.lodChunkRenderDistance.get() * LodUtil.CHUNK_WIDTH;
+38 -39
View File
@@ -23,6 +23,8 @@ import java.awt.Color;
import java.io.File;
import java.util.HashSet;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.lod.builders.bufferBuilding.lodTemplates.Box;
import com.seibel.lod.config.LodConfig;
import com.seibel.lod.enums.HorizontalResolution;
@@ -32,21 +34,18 @@ import com.seibel.lod.objects.RegionPos;
import com.seibel.lod.wrappers.MinecraftWrapper;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.CompiledChunk;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.IWorld;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.server.ServerChunkProvider;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.Heightmap;
/**
* This class holds methods and constants that may be used in multiple places.
@@ -128,7 +127,7 @@ public class LodUtil
/**
* 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;
public static final Heightmap.Types DEFAULT_HEIGHTMAP = Heightmap.Types.WORLD_SURFACE_WG;
/**
* This regex finds any characters that are invalid for use in a windows
@@ -150,43 +149,43 @@ public class LodUtil
public static final int MAX_ALLOCATABLE_DIRECT_MEMORY = 64 * 1024 * 1024;
public static final VertexFormat LOD_VERTEX_FORMAT = DefaultVertexFormats.POSITION_COLOR;
public static final VertexFormat LOD_VERTEX_FORMAT = DefaultVertexFormat.POSITION_COLOR;
/**
* Gets the first valid ServerWorld.
* @return null if there are no ServerWorlds
* Gets the first valid ServerLevel.
* @return null if there are no ServerLevels
*/
public static ServerWorld getFirstValidServerWorld()
public static ServerLevel getFirstValidServerLevel()
{
if (mc.hasSinglePlayerServer())
return null;
Iterable<ServerWorld> worlds = mc.getSinglePlayerServer().getAllLevels();
Iterable<ServerLevel> worlds = mc.getSinglePlayerServer().getAllLevels();
for (ServerWorld world : worlds)
for (ServerLevel world : worlds)
return world;
return null;
}
/**
* Gets the ServerWorld for the relevant dimension.
* @return null if there is no ServerWorld for the given dimension
* Gets the ServerLevel for the relevant dimension.
* @return null if there is no ServerLevel for the given dimension
*/
public static ServerWorld getServerWorldFromDimension(DimensionType dimension)
public static ServerLevel getServerLevelFromDimension(DimensionType dimension)
{
IntegratedServer server = mc.getSinglePlayerServer();
if (server == null)
return null;
Iterable<ServerWorld> worlds = server.getAllLevels();
ServerWorld returnWorld = null;
Iterable<ServerLevel> worlds = server.getAllLevels();
ServerLevel returnWorld = null;
for (ServerWorld world : worlds)
for (ServerLevel world : worlds)
{
if (world.dimensionType() == dimension)
{
@@ -217,11 +216,11 @@ public class LodUtil
* Return whether the given chunk
* has any data in it.
*/
public static boolean chunkHasBlockData(IChunk chunk)
public static boolean chunkHasBlockData(ChunkAccess chunk)
{
ChunkSection[] blockStorage = chunk.getSections();
LevelChunkSection[] blockStorage = chunk.getSections();
for (ChunkSection section : blockStorage)
for (LevelChunkSection section : blockStorage)
{
if (section != null && !section.isEmpty())
return true;
@@ -236,7 +235,7 @@ public class LodUtil
* world, if in multiplayer it will return the server name, IP,
* and game version.
*/
public static String getWorldID(IWorld world)
public static String getWorldID(Level world)
{
if (mc.hasSinglePlayerServer())
{
@@ -264,22 +263,22 @@ public class LodUtil
* This can be used to determine where to save files for a given
* dimension.
*/
public static String getDimensionIDFromWorld(IWorld world)
public static String getDimensionIDFromWorld(Level world)
{
if (mc.hasSinglePlayerServer())
{
// this will return the world save location
// and the dimension folder
ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(world.dimensionType());
if (serverWorld == null)
throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerWorld for the dimension " + world.dimensionType().effectsLocation().getPath());
ServerLevel ServerLevel = LodUtil.getServerLevelFromDimension(world.dimensionType());
if (ServerLevel == null)
throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerLevel for the dimension " + world.dimensionType().effectsLocation().getPath());
ServerChunkProvider provider = serverWorld.getChunkSource();
ServerChunkCache provider = ServerLevel.getChunkSource();
if (provider == null)
throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerChunkProvider for the dimension " + world.dimensionType().effectsLocation().getPath());
return provider.dataStorage.dataFolder.toString();
return provider.getDataStorage().dataFolder.toString();
}
else
{
@@ -456,8 +455,8 @@ public class LodUtil
// Wow, those are some long names!
// go through every RenderInfo to get the compiled chunks
WorldRenderer renderer = mc.getLevelRenderer();
for (WorldRenderer.LocalRenderInformationContainer worldRenderer$LocalRenderInformationContainer : renderer.renderChunks)
LevelRenderer renderer = mc.getLevelRenderer();
for (LevelRenderer.LocalRenderInformationContainer worldRenderer$LocalRenderInformationContainer : renderer.renderChunks)
{
CompiledChunk compiledChunk = worldRenderer$LocalRenderInformationContainer.chunk.getCompiledChunk();
if (!compiledChunk.hasNoRenderableLayers())
@@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentMap;
import com.seibel.lod.builders.bufferBuilding.lodTemplates.Box;
import net.minecraft.util.Direction;
import net.minecraft.core.Direction;
/**
* Holds data used by specific threads so
@@ -1,20 +1,27 @@
package com.seibel.lod.wrappers.Block;
import com.seibel.lod.util.ColorUtil;
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.util.math.BlockPos;
import net.minecraftforge.client.model.data.ModelDataMap;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.seibel.lod.util.ColorUtil;
import com.seibel.lod.wrappers.MinecraftWrapper;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.FlowerBlock;
import net.minecraft.world.level.block.GrassBlock;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.TallGrassBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelDataMap;
//This class wraps the minecraft Block class
public class BlockColorWrapper
@@ -22,7 +29,7 @@ public class BlockColorWrapper
//set of block which require tint
public static final ConcurrentMap<Block, BlockColorWrapper> blockColorWrapperMap = new ConcurrentHashMap<>();
public static final ModelDataMap dataMap = new ModelDataMap.Builder().build();
public static final BlockPos blockPos = new BlockPos(0,0,0);
public static final BlockPosWrapper blockPos = new BlockPosWrapper(0,0,0);
public static Random random = new Random(0);
//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 };
@@ -114,7 +121,7 @@ public class BlockColorWrapper
else
{
isColored = true;
texture = mc.getModelManager().getBlockModelShaper().getTexture(block.defaultBlockState(), mc.getClientWorld(), blockPosWrapper.getBlockPos());
texture = mc.getModelManager().getBlockModelShaper().getTexture(block.defaultBlockState(), mc.getClientLevel(), blockPosWrapper.getBlockPos());
}
int count = 0;
@@ -1,31 +1,30 @@
package com.seibel.lod.wrappers.Block;
import com.seibel.lod.util.ColorUtil;
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.util.math.BlockPos;
import net.minecraftforge.client.model.data.ModelDataMap;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper;
import net.minecraft.core.BlockPos;
//This class wraps the minecraft BlockPos.Mutable (and BlockPos) class
public class BlockPosWrapper
{
private BlockPos.Mutable blockPos;
private BlockPos.MutableBlockPos blockPos;
public BlockPosWrapper()
{
this.blockPos = new BlockPos.Mutable(0,0,0);
this.blockPos = new BlockPos.MutableBlockPos(0,0,0);
}
public BlockPosWrapper(int x, int y, int z)
{
this.blockPos = new BlockPos.MutableBlockPos(x, y, z);
}
public void set(int x, int y, int z)
{
blockPos.set(x, y, z);
@@ -46,7 +45,7 @@ public class BlockPosWrapper
return blockPos.getZ();
}
public BlockPos.Mutable getBlockPos()
public BlockPos.MutableBlockPos getBlockPos()
{
return blockPos;
}
@@ -60,5 +59,11 @@ public class BlockPosWrapper
{
return Objects.hash(blockPos);
}
public ChunkPosWrapper offset(int x, int y, int z)
{
// TODO Auto-generated method stub
return null;
}
}
@@ -1,23 +1,19 @@
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.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;
import com.seibel.lod.wrappers.Chunk.ChunkWrapper;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.shapes.VoxelShape;
//This class wraps the minecraft Block class
public class BlockShapeWrapper
@@ -71,7 +67,7 @@ public class BlockShapeWrapper
private void setupShapes(ChunkWrapper chunkWrapper, BlockPosWrapper blockPosWrapper)
{
IBlockReader chunk = chunkWrapper.getChunk();
ChunkAccess chunk = chunkWrapper.getChunk();
BlockPos blockPos = blockPosWrapper.getBlockPos();
boolean noCollisionSetted = false;
boolean nonFullSetted = false;
@@ -88,7 +84,7 @@ public class BlockShapeWrapper
if (!voxelShape.isEmpty())
{
AxisAlignedBB bbox = voxelShape.bounds();
AABB bbox = voxelShape.bounds();
double xWidth = (bbox.maxX - bbox.minX);
double yWidth = (bbox.maxY - bbox.minY);
double zWidth = (bbox.maxZ - bbox.minZ);
@@ -1,21 +1,47 @@
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.wrappers.Block.BlockPosWrapper;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
//This class wraps the minecraft ChunkPos class
public class ChunkPosWrapper
{
private ChunkPos chunkPos;
private net.minecraft.world.level.ChunkPos chunkPos;
public ChunkPosWrapper(ChunkPos chunkPos)
public ChunkPosWrapper(ChunkPos newChunkPos)
{
this.chunkPos = chunkPos;
this.chunkPos = newChunkPos;
}
public ChunkPosWrapper(BlockPos blockPos)
{
this.chunkPos = new ChunkPos(blockPos);
}
public ChunkPosWrapper(ChunkPosWrapper newChunkPos)
{
this.chunkPos = newChunkPos.chunkPos;
}
public ChunkPosWrapper(BlockPosWrapper blockPos)
{
this.chunkPos = new ChunkPos(blockPos.getBlockPos());
}
public ChunkPosWrapper(int chunkX, int chunkZ)
{
this.chunkPos = new ChunkPos(chunkX, chunkZ);
}
public int getX()
{
return chunkPos.x;
@@ -60,5 +86,10 @@ public class ChunkPosWrapper
{
return Objects.hash(chunkPos);
}
public BlockPosWrapper getWorldPosition()
{
return null;
}
}
@@ -5,16 +5,16 @@ import com.seibel.lod.wrappers.Block.BlockColorWrapper;
import com.seibel.lod.wrappers.Block.BlockPosWrapper;
import com.seibel.lod.wrappers.Block.BlockShapeWrapper;
import com.seibel.lod.wrappers.World.BiomeWrapper;
import net.minecraft.block.BlockState;
import net.minecraft.block.ILiquidContainer;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkAccess;
public class ChunkWrapper
{
private IChunk chunk;
private ChunkAccess chunk;
private ChunkPosWrapper chunkPos;
public int getHeight(){
@@ -26,7 +26,7 @@ public class ChunkWrapper
BlockState blockState = chunk.getBlockState(blockPos.getBlockPos());
//This type of block is always in water
if((blockState.getBlock() instanceof ILiquidContainer) && !(blockState.getBlock() instanceof IWaterLoggable))
if((blockState.getBlock() instanceof LiquidBlock) && !(blockState.getBlock() instanceof IWaterLoggable))
return true;
//This type of block could be in water
@@ -55,13 +55,13 @@ public class ChunkWrapper
return BlockShapeWrapper.getBlockShapeWrapper(chunk.getBlockState(blockPos.getBlockPos()).getBlock(), this, blockPos);
}
public ChunkWrapper(IChunk chunk)
public ChunkWrapper(ChunkAccess chunk)
{
this.chunk = chunk;
this.chunkPos = new ChunkPosWrapper(chunk.getPos());
}
public IChunk getChunk(){
public ChunkAccess getChunk(){
return chunk;
}
public ChunkPosWrapper getPos(){
@@ -22,30 +22,30 @@ package com.seibel.lod.wrappers;
import java.awt.Color;
import java.io.File;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.platform.Window;
import com.seibel.lod.ModInfo;
import com.seibel.lod.proxy.ClientProxy;
import com.seibel.lod.util.LodUtil;
import com.seibel.lod.wrappers.World.WorldWrapper;
import net.minecraft.client.GameSettings;
import net.minecraft.client.MainWindow;
import net.minecraft.CrashReport;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.Options;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.model.ModelManager;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.crash.CrashReport;
import net.minecraft.entity.Entity;
import net.minecraft.profiler.IProfiler;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.util.Direction;
import net.minecraft.world.DimensionType;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.dimension.DimensionType;
/**
* A singleton that wraps the Minecraft class
@@ -165,12 +165,12 @@ public class MinecraftWrapper
// Simple gets //
//=============//
public ClientPlayerEntity getPlayer()
public LocalPlayer getPlayer()
{
return mc.player;
}
public GameSettings getOptions()
public Options getOptions()
{
return mc.options;
}
@@ -180,17 +180,17 @@ public class MinecraftWrapper
return mc.getModelManager();
}
public ClientWorld getClientWorld()
public ClientLevel getClientLevel()
{
return mc.level;
}
public WorldWrapper getWrappedClientWorld()
public WorldWrapper getWrappedClientLevel()
{
return WorldWrapper.getWorldWrapper(mc.level);
}
public WorldWrapper getWrappedServerWorld()
public WorldWrapper getWrappedServerLevel()
{
if (mc.level == null)
@@ -200,10 +200,10 @@ public class MinecraftWrapper
if (server == null)
return null;
Iterable<ServerWorld> worlds = server.getAllLevels();
ServerWorld returnWorld = null;
Iterable<ServerLevel> worlds = server.getAllLevels();
ServerLevel returnWorld = null;
for (ServerWorld world : worlds)
for (ServerLevel world : worlds)
{
if (world.dimensionType() == dimension)
{
@@ -226,12 +226,12 @@ public class MinecraftWrapper
return mc.gameDirectory;
}
public IProfiler getProfiler()
public ProfilerFiller getProfiler()
{
return mc.getProfiler();
}
public ClientPlayNetHandler getConnection()
public ClientPacketListener getConnection()
{
return mc.getConnection();
}
@@ -246,7 +246,7 @@ public class MinecraftWrapper
return mc.cameraEntity;
}
public MainWindow getWindow()
public Window getWindow()
{
return mc.getWindow();
}
@@ -266,7 +266,7 @@ public class MinecraftWrapper
return mc.getCurrentServer();
}
public WorldRenderer getLevelRenderer()
public LevelRenderer getLevelRenderer()
{
return mc.levelRenderer;
}
@@ -1,10 +1,10 @@
package com.seibel.lod.wrappers.World;
import net.minecraft.world.DimensionType;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import net.minecraft.world.level.dimension.DimensionType;
public class DimensionTypeWrapper
{
private static final ConcurrentMap<DimensionType, DimensionTypeWrapper> dimensionTypeWrapperMap = new ConcurrentHashMap<>();