Start implementing IMinecraftWrapper
This commit is contained in:
@@ -31,10 +31,10 @@ import com.seibel.lod.core.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.core.util.ThreadMapUtil;
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
/**
|
||||
* This holds the methods that should be called
|
||||
@@ -51,7 +51,7 @@ public class ClientApi
|
||||
|
||||
public static LodRenderer renderer = new LodRenderer(ApiShared.lodBufferBuilderFactory);
|
||||
|
||||
private final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
private final EventApi eventApi = EventApi.INSTANCE;
|
||||
private final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ClientApi
|
||||
firstFrameSetup();
|
||||
|
||||
|
||||
if (mc.getPlayer() == null || ApiShared.lodWorld.getIsWorldNotLoaded())
|
||||
if (!mc.playerExists() || ApiShared.lodWorld.getIsWorldNotLoaded())
|
||||
return;
|
||||
|
||||
LodDimension lodDim = ApiShared.lodWorld.getLodDimension(mc.getCurrentDimension());
|
||||
@@ -98,8 +98,8 @@ public class ClientApi
|
||||
eventApi.viewDistanceChangedEvent();
|
||||
eventApi.playerMoveEvent(lodDim);
|
||||
|
||||
lodDim.cutRegionNodesAsync((int) mc.getPlayer().getX(), (int) mc.getPlayer().getZ());
|
||||
lodDim.expandOrLoadRegionsAsync((int) mc.getPlayer().getX(), (int) mc.getPlayer().getZ());
|
||||
lodDim.cutRegionNodesAsync(mc.getPlayerBlockPos().getX(), mc.getPlayerBlockPos().getZ());
|
||||
lodDim.expandOrLoadRegionsAsync(mc.getPlayerBlockPos().getX(), mc.getPlayerBlockPos().getZ());
|
||||
|
||||
|
||||
// Note to self:
|
||||
@@ -139,7 +139,7 @@ public class ClientApi
|
||||
// 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 StringTextComponent("Debug settings enabled!"), mc.getPlayer().getUUID());
|
||||
mc.sendChatMessage("Debug settings enabled!");
|
||||
configOverrideReminderPrinted = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.seibel.lod.core.util.ThreadMapUtil;
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperAdapters.chunk.IChunkWrapper;
|
||||
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.minecraft.MinecraftWrapper;
|
||||
@@ -49,7 +50,7 @@ public class EventApi
|
||||
{
|
||||
public static final EventApi INSTANCE = new EventApi();
|
||||
|
||||
private final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
private final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
/**
|
||||
@@ -73,7 +74,7 @@ public class EventApi
|
||||
|
||||
public void serverTickEvent()
|
||||
{
|
||||
if (mc.getPlayer() == null || ApiShared.lodWorld.getIsWorldNotLoaded())
|
||||
if (!mc.playerExists() || ApiShared.lodWorld.getIsWorldNotLoaded())
|
||||
return;
|
||||
|
||||
LodDimension lodDim = ApiShared.lodWorld.getLodDimension(mc.getCurrentDimension());
|
||||
@@ -121,7 +122,7 @@ public class EventApi
|
||||
ThreadMapUtil.clearMaps();
|
||||
|
||||
|
||||
if (mc.getConnection().getLevel() == null)
|
||||
if (mc.getWrappedClientWorld() == null)
|
||||
{
|
||||
// the player just left the server
|
||||
|
||||
@@ -198,7 +199,7 @@ public class EventApi
|
||||
{
|
||||
// calculate how wide the dimension(s) should be in regions
|
||||
int chunksWide;
|
||||
if (mc.getClientWorld().dimensionType().hasCeiling())
|
||||
if (mc.getWrappedClientWorld().getDimensionType().hasCeiling())
|
||||
chunksWide = Math.min(config.client().graphics().quality().getLodChunkRenderDistance(), LodUtil.CEILED_DIMENSION_MAX_RENDER_DISTANCE) * 2 + 1;
|
||||
else
|
||||
chunksWide = config.client().graphics().quality().getLodChunkRenderDistance() * 2 + 1;
|
||||
|
||||
+3
-1
@@ -58,6 +58,7 @@ 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.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.minecraft.MinecraftWrapper;
|
||||
@@ -72,6 +73,7 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
public class LodBufferBuilderFactory
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
/** The thread used to generate new LODs off the main thread. */
|
||||
public static final ExecutorService mainGenThread = Executors.newSingleThreadExecutor(new LodThreadFactory(LodBufferBuilderFactory.class.getSimpleName() + " - main"));
|
||||
@@ -231,7 +233,7 @@ public class LodBufferBuilderFactory
|
||||
// create the nodeToRenderThreads //
|
||||
//================================//
|
||||
|
||||
skyLightPlayer = MinecraftWrapper.INSTANCE.getWrappedClientWorld().getSkyLight(playerBlockPos);
|
||||
skyLightPlayer = mc.getWrappedClientWorld().getSkyLight(playerBlockPos);
|
||||
|
||||
for (int xRegion = 0; xRegion < lodDim.getWidth(); xRegion++)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.seibel.lod.core.wrapperAdapters.block.IBlockColorWrapper;
|
||||
import com.seibel.lod.core.wrapperAdapters.block.IBlockShapeWrapper;
|
||||
import com.seibel.lod.core.wrapperAdapters.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
||||
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;
|
||||
@@ -57,7 +58,7 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
*/
|
||||
public class LodBuilder
|
||||
{
|
||||
private static final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private static final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
private static final IBlockColorSingletonWrapper blockColorSingleton = SingletonHandler.get(IBlockColorSingletonWrapper.class);
|
||||
|
||||
private final ExecutorService lodGenThreadPool = Executors.newSingleThreadExecutor(new LodThreadFactory(this.getClass().getSimpleName()));
|
||||
@@ -109,12 +110,12 @@ public class LodBuilder
|
||||
{
|
||||
// we need a loaded client world in order to
|
||||
// get the textures for blocks
|
||||
if (mc.getClientWorld() == null)
|
||||
if (mc.getWrappedClientWorld() == null)
|
||||
return;
|
||||
|
||||
// don't try to generate LODs if the user isn't in the world anymore
|
||||
// (this happens a lot when the user leaves a world/server)
|
||||
if (mc.getSinglePlayerServer() == null && mc.getCurrentServer() == null)
|
||||
if (!mc.hasSinglePlayerServer() && !mc.connectedToServer())
|
||||
return;
|
||||
|
||||
// make sure the dimension exists
|
||||
@@ -169,7 +170,7 @@ public class LodBuilder
|
||||
return;
|
||||
|
||||
// this happens if a LOD is generated after the user leaves the world.
|
||||
if (MinecraftWrapper.INSTANCE.getWrappedClientWorld() == null)
|
||||
if (mc.getWrappedClientWorld() == null)
|
||||
return;
|
||||
|
||||
// determine how many LODs to generate horizontally
|
||||
@@ -229,8 +230,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.getWrappedClientWorld().getDimensionType().hasCeiling();
|
||||
boolean hasSkyLight = mc.getWrappedClientWorld().getDimensionType().hasSkyLight();
|
||||
boolean isDefault;
|
||||
BlockPosWrapper blockPos = new BlockPosWrapper();
|
||||
int index;
|
||||
@@ -385,7 +386,7 @@ public class LodBuilder
|
||||
// 1 means the lighting is a guess
|
||||
int isDefault = 0;
|
||||
|
||||
IWorldWrapper world = MinecraftWrapper.INSTANCE.getWrappedServerWorld();
|
||||
IWorldWrapper world = mc.getWrappedServerWorld();
|
||||
|
||||
int blockBrightness = chunk.getEmittedBrightness(blockPos);
|
||||
// get the air block above or below this block
|
||||
@@ -413,7 +414,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.getWrappedClientWorld().getSeaLevel() - 5)
|
||||
{
|
||||
skyLight = 12;
|
||||
isDefault = 1;
|
||||
@@ -424,7 +425,7 @@ public class LodBuilder
|
||||
}
|
||||
else
|
||||
{
|
||||
world = MinecraftWrapper.INSTANCE.getWrappedServerWorld();
|
||||
world = mc.getWrappedServerWorld();
|
||||
if (world.isEmpty())
|
||||
return 0;
|
||||
// client world sky light (almost never accurate)
|
||||
@@ -446,7 +447,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.getWrappedClientWorld().getSeaLevel() - 5)
|
||||
{
|
||||
skyLight = 12;
|
||||
isDefault = 1;
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.seibel.lod.core.util.LodThreadFactory;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.core.wrapperAdapters.world.IWorldWrapper;
|
||||
import com.seibel.lod.wrappers.chunk.ChunkPosWrapper;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
@@ -50,7 +51,7 @@ import net.minecraftforge.common.WorldWorkerManager;
|
||||
*/
|
||||
public class LodWorldGenerator
|
||||
{
|
||||
public final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private static final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
/** This holds the thread used to generate new LODs off the main thread. */
|
||||
private final ExecutorService mainGenThread = Executors.newSingleThreadExecutor(new LodThreadFactory(this.getClass().getSimpleName() + " world generator"));
|
||||
@@ -111,8 +112,8 @@ public class LodWorldGenerator
|
||||
try
|
||||
{
|
||||
// round the player's block position down to the nearest chunk BlockPos
|
||||
int playerPosX = mc.getPlayer().blockPosition().getX();
|
||||
int playerPosZ = mc.getPlayer().blockPosition().getZ();
|
||||
int playerPosX = mc.getPlayerBlockPos().getX();
|
||||
int playerPosZ = mc.getPlayerBlockPos().getZ();
|
||||
|
||||
|
||||
//=======================================//
|
||||
|
||||
@@ -31,6 +31,7 @@ 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.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.block.BlockPosWrapper;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
|
||||
@@ -42,6 +43,7 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
public class Box
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private static final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
public static final int ADJACENT_HEIGHT_INDEX = 0;
|
||||
public static final int ADJACENT_DEPTH_INDEX = 1;
|
||||
@@ -256,7 +258,7 @@ public class Box
|
||||
for (LodDirection lodDirection : DIRECTIONS)
|
||||
{
|
||||
if (!adjShadeDisabled[DIRECTION_INDEX.get(lodDirection)])
|
||||
colorMap[DIRECTION_INDEX.get(lodDirection)] = ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getShade(lodDirection));
|
||||
colorMap[DIRECTION_INDEX.get(lodDirection)] = ColorUtil.applyShade(color, mc.getShade(lodDirection));
|
||||
else
|
||||
colorMap[DIRECTION_INDEX.get(lodDirection)] = color;
|
||||
}
|
||||
@@ -271,7 +273,7 @@ public class Box
|
||||
if (config.client().advanced().debugging().getDebugMode() != DebugMode.SHOW_DETAIL)
|
||||
return colorMap[DIRECTION_INDEX.get(lodDirection)];
|
||||
else
|
||||
return ColorUtil.applyShade(color, MinecraftWrapper.INSTANCE.getShade(lodDirection));
|
||||
return ColorUtil.applyShade(color, mc.getShade(lodDirection));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.seibel.lod.core.util.LodThreadFactory;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
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.chunk.ChunkPosWrapper;
|
||||
@@ -59,6 +60,7 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
public class LodDimension
|
||||
{
|
||||
private final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
public final IDimensionTypeWrapper dimension;
|
||||
|
||||
@@ -106,7 +108,6 @@ public class LodDimension
|
||||
dimension = newDimension;
|
||||
width = newWidth;
|
||||
halfWidth = width / 2;
|
||||
MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
|
||||
if (newDimension != null && lodWorld != null)
|
||||
{
|
||||
|
||||
@@ -33,6 +33,8 @@ import com.seibel.lod.api.lod.ClientApi;
|
||||
import com.seibel.lod.core.enums.rendering.GlProxyContext;
|
||||
import com.seibel.lod.core.render.shader.LodShader;
|
||||
import com.seibel.lod.core.render.shader.LodShaderProgram;
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
|
||||
/**
|
||||
@@ -53,7 +55,7 @@ public class GlProxy
|
||||
{
|
||||
private static GlProxy instance = null;
|
||||
|
||||
private static MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private static IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
|
||||
/** Minecraft's GLFW window */
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.seibel.lod.core.enums.rendering.DebugMode;
|
||||
import com.seibel.lod.core.enums.rendering.FogDistance;
|
||||
import com.seibel.lod.core.enums.rendering.FogDrawOverride;
|
||||
import com.seibel.lod.core.enums.rendering.FogQuality;
|
||||
import com.seibel.lod.core.handlers.ReflectionHandler;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
import com.seibel.lod.core.objects.lod.RegionPos;
|
||||
import com.seibel.lod.core.objects.math.Mat4f;
|
||||
@@ -46,8 +45,10 @@ 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.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.McObjectConverter;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
|
||||
@@ -80,7 +81,7 @@ public class LodRenderer
|
||||
*/
|
||||
public DebugMode previousDebugMode = DebugMode.OFF;
|
||||
|
||||
private final MinecraftWrapper mc;
|
||||
private final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
private final GameRenderer gameRender;
|
||||
private final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private IProfiler profiler;
|
||||
@@ -252,7 +253,7 @@ public class LodRenderer
|
||||
Mat4f modelViewMatrix = offsetTheModelViewMatrix(mcModelViewMatrix, partialTicks);
|
||||
vanillaBlockRenderedDistance = mc.getRenderDistance() * LodUtil.CHUNK_WIDTH;
|
||||
// required for setupFog and setupProjectionMatrix
|
||||
if (mc.getClientWorld().dimensionType().hasCeiling())
|
||||
if (mc.getWrappedClientWorld().getDimensionType().hasCeiling())
|
||||
farPlaneBlockDistance = Math.min(config.client().graphics().quality().getLodChunkRenderDistance(), LodUtil.CEILED_DIMENSION_MAX_RENDER_DISTANCE) * LodUtil.CHUNK_WIDTH;
|
||||
else
|
||||
farPlaneBlockDistance = config.client().graphics().quality().getLodChunkRenderDistance() * LodUtil.CHUNK_WIDTH;
|
||||
@@ -943,7 +944,7 @@ public class LodRenderer
|
||||
|
||||
|
||||
// if the player is high enough, draw all LODs
|
||||
if (chunkPosToSkip.isEmpty() && mc.getPlayer().position().y > 256 && !vanillaRenderedChunksEmptySkip)
|
||||
if (chunkPosToSkip.isEmpty() && mc.getPlayerBlockPos().getY() > 256 && !vanillaRenderedChunksEmptySkip)
|
||||
{
|
||||
vanillaRenderedChunks = new boolean[vanillaRenderedChunksWidth][vanillaRenderedChunksWidth];
|
||||
vanillaRenderedChunksChanged = true;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
package com.seibel.lod.core.render;
|
||||
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
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.minecraft.MinecraftWrapper;
|
||||
@@ -36,7 +38,7 @@ import net.minecraft.util.math.vector.Vector3f;
|
||||
*/
|
||||
public class RenderUtil
|
||||
{
|
||||
private static final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private static final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ package com.seibel.lod.core.util;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
|
||||
/**
|
||||
@@ -31,6 +33,9 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
*/
|
||||
public class ColorUtil
|
||||
{
|
||||
private static final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
|
||||
public static int rgbToInt(int red, int green, int blue)
|
||||
{
|
||||
return (0xFF << 24) | (red << 16) | (green << 8) | blue;
|
||||
@@ -84,7 +89,7 @@ public class ColorUtil
|
||||
/** This method apply the lightmap to the color to use */
|
||||
public static int applyLightValue(int color, int skyLight, int blockLight)
|
||||
{
|
||||
int lightColor = MinecraftWrapper.INSTANCE.getColorIntFromLightMap(blockLight, skyLight);
|
||||
int lightColor = mc.getColorIntFromLightMap(blockLight, skyLight);
|
||||
int red = ColorUtil.getBlue(lightColor);
|
||||
int green = ColorUtil.getGreen(lightColor);
|
||||
int blue = ColorUtil.getRed(lightColor);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.seibel.lod.core.enums.config.HorizontalQuality;
|
||||
import com.seibel.lod.core.enums.config.HorizontalResolution;
|
||||
import com.seibel.lod.core.wrapperAdapters.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperAdapters.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
|
||||
/**
|
||||
@@ -34,6 +35,7 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
public class DetailDistanceUtil
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
private static final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
|
||||
private static final double genMultiplier = 1.0;
|
||||
private static final double treeGenMultiplier = 1.0;
|
||||
@@ -42,7 +44,7 @@ public class DetailDistanceUtil
|
||||
private static byte minDrawDetail = (byte) Math.max(config.client().graphics().quality().getDrawResolution().detailLevel, config.client().graphics().quality().getDrawResolution().detailLevel);
|
||||
private static final int maxDetail = LodUtil.REGION_DETAIL_LEVEL + 1;
|
||||
private static final int minDistance = 0;
|
||||
private static int minDetailDistance = (int) (MinecraftWrapper.INSTANCE.getRenderDistance()*16 * 1.42f);
|
||||
private static int minDetailDistance = (int) (mc.getRenderDistance()*16 * 1.42f);
|
||||
private static int maxDistance = config.client().graphics().quality().getLodChunkRenderDistance() * 16 * 2;
|
||||
|
||||
|
||||
@@ -63,7 +65,7 @@ public class DetailDistanceUtil
|
||||
|
||||
public static void updateSettings()
|
||||
{
|
||||
minDetailDistance = (int) (MinecraftWrapper.INSTANCE.getRenderDistance()*16 * 1.42f);
|
||||
minDetailDistance = (int) (mc.getRenderDistance()*16 * 1.42f);
|
||||
minGenDetail = config.client().graphics().quality().getDrawResolution().detailLevel;
|
||||
minDrawDetail = (byte) Math.max(config.client().graphics().quality().getDrawResolution().detailLevel, config.client().graphics().quality().getDrawResolution().detailLevel);
|
||||
maxDistance = config.client().graphics().quality().getLodChunkRenderDistance() * 16 * 8;
|
||||
|
||||
@@ -33,6 +33,7 @@ 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.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;
|
||||
@@ -42,13 +43,11 @@ import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.CompiledChunk;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.chunk.ChunkSection;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
/**
|
||||
* This class holds methods and constants that may be used in multiple places.
|
||||
@@ -58,7 +57,7 @@ import net.minecraft.world.server.ServerWorld;
|
||||
*/
|
||||
public class LodUtil
|
||||
{
|
||||
private static final MinecraftWrapper mc = MinecraftWrapper.INSTANCE;
|
||||
private static final IMinecraftWrapper mc = SingletonHandler.get(MinecraftWrapper.class);
|
||||
private static final ILodConfigWrapperSingleton config = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
/**
|
||||
@@ -163,18 +162,18 @@ public class LodUtil
|
||||
* Gets the first valid ServerWorld.
|
||||
* @return null if there are no ServerWorlds
|
||||
*/
|
||||
public static ServerWorld getFirstValidServerWorld()
|
||||
{
|
||||
if (mc.hasSinglePlayerServer())
|
||||
return null;
|
||||
|
||||
Iterable<ServerWorld> worlds = mc.getSinglePlayerServer().getAllLevels();
|
||||
|
||||
for (ServerWorld world : worlds)
|
||||
return world;
|
||||
|
||||
return null;
|
||||
}
|
||||
// public static ServerWorld getFirstValidServerWorld()
|
||||
// {
|
||||
// if (mc.hasSinglePlayerServer())
|
||||
// return null;
|
||||
//
|
||||
// Iterable<ServerWorld> worlds = mc.getSinglePlayerServer().getAllLevels();
|
||||
//
|
||||
// for (ServerWorld world : worlds)
|
||||
// return world;
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the ServerWorld for the relevant dimension.
|
||||
@@ -182,8 +181,7 @@ public class LodUtil
|
||||
*/
|
||||
public static IWorldWrapper getServerWorldFromDimension(IDimensionTypeWrapper newDimension)
|
||||
{
|
||||
IntegratedServer server = mc.getSinglePlayerServer();
|
||||
if (server == null)
|
||||
if(!mc.hasSinglePlayerServer())
|
||||
return null;
|
||||
|
||||
Iterable<IWorldWrapper> worlds = mc.getAllServerWorlds();
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizon mod (formerly the LOD Mod),
|
||||
* licensed under the GNU GPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.core.wrapperAdapters.minecraft;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
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;
|
||||
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
|
||||
/**
|
||||
* A singleton that wraps the Minecraft class
|
||||
* to allow for easier movement between Minecraft versions.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 9-16-2021
|
||||
*/
|
||||
public interface IMinecraftWrapper
|
||||
{
|
||||
//================//
|
||||
// helper methods //
|
||||
//================//
|
||||
|
||||
/**
|
||||
* This should be called at the beginning of every frame to
|
||||
* clear any Minecraft data that becomes out of date after a frame. <br> <br>
|
||||
* <p>
|
||||
* LightMaps and other time sensitive objects fall in this category. <br> <br>
|
||||
* <p>
|
||||
* This doesn't affect OpenGL objects in any way.
|
||||
*/
|
||||
public void clearFrameObjectCache();
|
||||
|
||||
|
||||
|
||||
//=================//
|
||||
// method wrappers //
|
||||
//=================//
|
||||
|
||||
public float getShade(LodDirection lodDirection);
|
||||
|
||||
public boolean hasSinglePlayerServer();
|
||||
|
||||
/** Returns the dimension the player is currently in */
|
||||
public DimensionTypeWrapper getCurrentDimension();
|
||||
|
||||
public String getCurrentDimensionId();
|
||||
|
||||
/** This texture changes every frame */
|
||||
ILightMapWrapper getCurrentLightMap();
|
||||
|
||||
/**
|
||||
* Returns the color int at the given pixel coordinates
|
||||
* from the current lightmap.
|
||||
* @param u x location in texture space
|
||||
* @param v z location in texture space
|
||||
*/
|
||||
public int getColorIntFromLightMap(int u, int v);
|
||||
|
||||
/**
|
||||
* Returns the Color at the given pixel coordinates
|
||||
* from the current lightmap.
|
||||
* @param u x location in texture space
|
||||
* @param v z location in texture space
|
||||
*/
|
||||
public Color getColorFromLightMap(int u, int v);
|
||||
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// Simple gets //
|
||||
//=============//
|
||||
|
||||
public boolean playerExists();
|
||||
|
||||
public BlockPosWrapper getPlayerBlockPos();
|
||||
|
||||
public ChunkPosWrapper getPlayerChunkPos();
|
||||
|
||||
/**
|
||||
* Attempts to get the ServerWorld for the dimension
|
||||
* the user is currently in.
|
||||
* @returns null if no ServerWorld is available
|
||||
*/
|
||||
public WorldWrapper getWrappedServerWorld();
|
||||
|
||||
public WorldWrapper getWrappedClientWorld();
|
||||
|
||||
/** Measured in chunks */
|
||||
public int getRenderDistance();
|
||||
|
||||
public File getGameDirectory();
|
||||
|
||||
public IProfiler getProfiler();
|
||||
|
||||
public float getSkyDarken(float partialTicks);
|
||||
|
||||
boolean connectedToServer();
|
||||
|
||||
/** Returns all worlds available to the server */
|
||||
public ArrayList<IWorldWrapper> getAllServerWorlds();
|
||||
|
||||
|
||||
|
||||
public void sendChatMessage(String string);
|
||||
|
||||
/**
|
||||
* Crashes Minecraft, displaying the given errorMessage <br> <br>
|
||||
* In the following format: <br>
|
||||
*
|
||||
* The game crashed whilst <strong>errorMessage</strong> <br>
|
||||
* Error: <strong>ExceptionClass: exceptionErrorMessage</strong> <br>
|
||||
* Exit Code: -1 <br>
|
||||
*/
|
||||
public void crashMinecraft(String errorMessage, Throwable exception);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.seibel.lod.core.wrapperAdapters.misc;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Leonardo Amato
|
||||
* @version 11-13-2021
|
||||
*/
|
||||
public interface ILightMapWrapper
|
||||
{
|
||||
public void setLightMap(NativeImage newlightMap);
|
||||
|
||||
public int getLightValue(int skyLight, int blockLight);
|
||||
}
|
||||
@@ -3,8 +3,10 @@ package com.seibel.lod.wrappers;
|
||||
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.minecraft.IMinecraftWrapper;
|
||||
import com.seibel.lod.wrappers.block.BlockColorSingletonWrapper;
|
||||
import com.seibel.lod.wrappers.config.LodConfigWrapperSingleton;
|
||||
import com.seibel.lod.wrappers.minecraft.MinecraftWrapper;
|
||||
|
||||
/**
|
||||
* Binds all necessary dependencies so we
|
||||
@@ -21,5 +23,6 @@ public class DependencySetup
|
||||
{
|
||||
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
|
||||
SingletonHandler.bind(IBlockColorSingletonWrapper.class, BlockColorSingletonWrapper.INSTANCE);
|
||||
SingletonHandler.bind(IMinecraftWrapper.class, MinecraftWrapper.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +1,73 @@
|
||||
package com.seibel.lod.wrappers.block;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.wrapperAdapters.block.AbstractBlockPosWrapper;
|
||||
|
||||
public class BlockPosWrapper {
|
||||
private final BlockPos.Mutable blockPos;
|
||||
|
||||
|
||||
public BlockPosWrapper()
|
||||
{
|
||||
this.blockPos = new BlockPos.Mutable(0,0,0);
|
||||
}
|
||||
|
||||
public BlockPosWrapper(int x, int y, int z)
|
||||
{
|
||||
this.blockPos = new BlockPos.Mutable(x, y, z);
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z)
|
||||
{
|
||||
blockPos.set(x, y, z);
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return blockPos.getX();
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return blockPos.getY();
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return blockPos.getZ();
|
||||
}
|
||||
|
||||
public int get(LodDirection.Axis axis)
|
||||
{
|
||||
return axis.choose(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public BlockPos.Mutable getBlockPos()
|
||||
{
|
||||
return blockPos;
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o)
|
||||
{
|
||||
return blockPos.equals(o);
|
||||
}
|
||||
|
||||
@Override public int hashCode()
|
||||
{
|
||||
return Objects.hash(blockPos);
|
||||
}
|
||||
|
||||
public BlockPosWrapper offset(int x, int y, int z)
|
||||
{
|
||||
blockPos.set(blockPos.getX() + x, blockPos.getY() + y, blockPos.getZ() + z);
|
||||
return this;
|
||||
}
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class BlockPosWrapper extends AbstractBlockPosWrapper
|
||||
{
|
||||
private final BlockPos.Mutable blockPos;
|
||||
|
||||
|
||||
public BlockPosWrapper()
|
||||
{
|
||||
this.blockPos = new BlockPos.Mutable(0, 0, 0);
|
||||
}
|
||||
|
||||
public BlockPosWrapper(int x, int y, int z)
|
||||
{
|
||||
this.blockPos = new BlockPos.Mutable(x, y, z);
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z)
|
||||
{
|
||||
blockPos.set(x, y, z);
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return blockPos.getX();
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return blockPos.getY();
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return blockPos.getZ();
|
||||
}
|
||||
|
||||
public int get(LodDirection.Axis axis)
|
||||
{
|
||||
return axis.choose(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public BlockPos.Mutable getBlockPos()
|
||||
{
|
||||
return blockPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return blockPos.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(blockPos);
|
||||
}
|
||||
|
||||
public BlockPosWrapper offset(int x, int y, int z)
|
||||
{
|
||||
blockPos.set(blockPos.getX() + x, blockPos.getY() + y, blockPos.getZ() + z);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.lod.core.handlers;
|
||||
package com.seibel.lod.wrappers.handlers;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -27,9 +27,12 @@ import com.seibel.lod.ModInfo;
|
||||
import com.seibel.lod.api.lod.ClientApi;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperAdapters.minecraft.IMinecraftWrapper;
|
||||
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.misc.LightMapWrapper;
|
||||
import com.seibel.lod.wrappers.world.DimensionTypeWrapper;
|
||||
import com.seibel.lod.wrappers.world.WorldWrapper;
|
||||
|
||||
@@ -51,6 +54,7 @@ import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
@@ -61,7 +65,7 @@ import net.minecraft.world.server.ServerWorld;
|
||||
* @author James Seibel
|
||||
* @version 9-16-2021
|
||||
*/
|
||||
public class MinecraftWrapper
|
||||
public class MinecraftWrapper implements IMinecraftWrapper
|
||||
{
|
||||
public static final MinecraftWrapper INSTANCE = new MinecraftWrapper();
|
||||
|
||||
@@ -92,6 +96,7 @@ public class MinecraftWrapper
|
||||
* <p>
|
||||
* This doesn't affect OpenGL objects in any way.
|
||||
*/
|
||||
@Override
|
||||
public void clearFrameObjectCache()
|
||||
{
|
||||
lightMap = null;
|
||||
@@ -103,32 +108,35 @@ public class MinecraftWrapper
|
||||
// method wrappers //
|
||||
//=================//
|
||||
|
||||
@Override
|
||||
public float getShade(LodDirection lodDirection)
|
||||
{
|
||||
Direction mcDir = McObjectConverter.Convert(lodDirection);
|
||||
return mc.level.getShade(mcDir, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSinglePlayerServer()
|
||||
{
|
||||
return mc.hasSingleplayerServer();
|
||||
}
|
||||
|
||||
/** Returns the dimension the player is currently in */
|
||||
@Override
|
||||
public DimensionTypeWrapper getCurrentDimension()
|
||||
{
|
||||
return DimensionTypeWrapper.getDimensionTypeWrapper(mc.player.level.dimensionType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentDimensionId()
|
||||
{
|
||||
return LodUtil.getDimensionIDFromWorld(WorldWrapper.getWorldWrapper(mc.level));
|
||||
}
|
||||
|
||||
/**
|
||||
* This texture changes every frame
|
||||
*/
|
||||
public NativeImage getCurrentLightMap()
|
||||
/** This texture changes every frame */
|
||||
@Override
|
||||
public ILightMapWrapper getCurrentLightMap()
|
||||
{
|
||||
// get the current lightMap if the cache is empty
|
||||
if (lightMap == null)
|
||||
@@ -136,7 +144,7 @@ public class MinecraftWrapper
|
||||
LightTexture tex = mc.gameRenderer.lightTexture();
|
||||
lightMap = tex.lightPixels;
|
||||
}
|
||||
return lightMap;
|
||||
return new LightMapWrapper(lightMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,6 +153,7 @@ public class MinecraftWrapper
|
||||
* @param u x location in texture space
|
||||
* @param v z location in texture space
|
||||
*/
|
||||
@Override
|
||||
public int getColorIntFromLightMap(int u, int v)
|
||||
{
|
||||
if (lightMap == null)
|
||||
@@ -162,6 +171,7 @@ public class MinecraftWrapper
|
||||
* @param u x location in texture space
|
||||
* @param v z location in texture space
|
||||
*/
|
||||
@Override
|
||||
public Color getColorFromLightMap(int u, int v)
|
||||
{
|
||||
return LodUtil.intToColor(lightMap.getPixelRGBA(u, v));
|
||||
@@ -179,12 +189,20 @@ public class MinecraftWrapper
|
||||
return mc.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerExists()
|
||||
{
|
||||
return mc.player != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPosWrapper getPlayerBlockPos()
|
||||
{
|
||||
BlockPos playerPos = getPlayer().blockPosition();
|
||||
return new BlockPosWrapper(playerPos.getX(), playerPos.getY(), playerPos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkPosWrapper getPlayerChunkPos()
|
||||
{
|
||||
return new ChunkPosWrapper(getPlayer().xChunk, getPlayer().zChunk);
|
||||
@@ -210,6 +228,7 @@ public class MinecraftWrapper
|
||||
* the user is currently in.
|
||||
* @returns null if no ServerWorld is available
|
||||
*/
|
||||
@Override
|
||||
public WorldWrapper getWrappedServerWorld()
|
||||
{
|
||||
if (mc.level == null)
|
||||
@@ -234,22 +253,26 @@ public class MinecraftWrapper
|
||||
return WorldWrapper.getWorldWrapper(serverWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldWrapper getWrappedClientWorld()
|
||||
{
|
||||
return WorldWrapper.getWorldWrapper(mc.level);
|
||||
}
|
||||
|
||||
/** Measured in chunks */
|
||||
@Override
|
||||
public int getRenderDistance()
|
||||
{
|
||||
return mc.options.renderDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getGameDirectory()
|
||||
{
|
||||
return mc.gameDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProfiler getProfiler()
|
||||
{
|
||||
return mc.getProfiler();
|
||||
@@ -275,6 +298,7 @@ public class MinecraftWrapper
|
||||
return mc.getWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSkyDarken(float partialTicks)
|
||||
{
|
||||
return mc.level.getSkyDarken(partialTicks);
|
||||
@@ -285,6 +309,12 @@ public class MinecraftWrapper
|
||||
return mc.getSingleplayerServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean connectedToServer()
|
||||
{
|
||||
return mc.getCurrentServer() != null;
|
||||
}
|
||||
|
||||
public ServerData getCurrentServer()
|
||||
{
|
||||
return mc.getCurrentServer();
|
||||
@@ -296,6 +326,7 @@ public class MinecraftWrapper
|
||||
}
|
||||
|
||||
/** Returns all worlds available to the server */
|
||||
@Override
|
||||
public ArrayList<IWorldWrapper> getAllServerWorlds()
|
||||
{
|
||||
ArrayList<IWorldWrapper> worlds = new ArrayList<IWorldWrapper>();
|
||||
@@ -311,6 +342,12 @@ public class MinecraftWrapper
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void sendChatMessage(String string)
|
||||
{
|
||||
getPlayer().sendMessage(new StringTextComponent("Debug settings enabled!"), getPlayer().getUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Crashes Minecraft, displaying the given errorMessage <br> <br>
|
||||
* In the following format: <br>
|
||||
@@ -319,13 +356,14 @@ public class MinecraftWrapper
|
||||
* Error: <strong>ExceptionClass: exceptionErrorMessage</strong> <br>
|
||||
* Exit Code: -1 <br>
|
||||
*/
|
||||
@Override
|
||||
public void crashMinecraft(String errorMessage, Throwable exception)
|
||||
{
|
||||
ClientApi.LOGGER.error(ModInfo.READABLE_NAME + " had the following error: [" + errorMessage + "]. Crashing Minecraft...");
|
||||
CrashReport report = new CrashReport(errorMessage, exception);
|
||||
Minecraft.crash(report);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.seibel.lod.wrappers.misc;
|
||||
|
||||
import com.seibel.lod.core.wrapperAdapters.misc.ILightMapWrapper;
|
||||
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
|
||||
/**
|
||||
@@ -7,16 +9,23 @@ import net.minecraft.client.renderer.texture.NativeImage;
|
||||
* @author Leonardo Amato
|
||||
* @version 11-13-2021
|
||||
*/
|
||||
public class LightMapWrapper
|
||||
public class LightMapWrapper implements ILightMapWrapper
|
||||
{
|
||||
static NativeImage lightMap = null;
|
||||
private NativeImage lightMap = null;
|
||||
|
||||
public static void setLightMap(NativeImage newlightMap)
|
||||
public LightMapWrapper(NativeImage newlightMap)
|
||||
{
|
||||
lightMap = newlightMap;
|
||||
}
|
||||
|
||||
public static int getLightValue(int skyLight, int blockLight)
|
||||
@Override
|
||||
public void setLightMap(NativeImage newlightMap)
|
||||
{
|
||||
lightMap = newlightMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(int skyLight, int blockLight)
|
||||
{
|
||||
return lightMap.getPixelRGBA(skyLight, blockLight);
|
||||
}
|
||||
|
||||
@@ -134,5 +134,11 @@ public class WorldWrapper implements IWorldWrapper
|
||||
return (ServerWorld) world;
|
||||
}
|
||||
|
||||
public int getSeaLevel()
|
||||
{
|
||||
// TODO this is depreciated, what should we use instead?
|
||||
return world.getSeaLevel();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user