Apply editorconfig auto formatting
This commit is contained in:
@@ -18,12 +18,12 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverri
|
||||
* This is the masthead of the API, almost everything you could want to do
|
||||
* can be achieved from here. <br>
|
||||
* For example: you can access singletons which handle the config or event binding. <br><br>
|
||||
*
|
||||
*
|
||||
* <strong>Q:</strong> Why should I use this class instead of just getting the API singleton I need? <br>
|
||||
*
|
||||
*
|
||||
* <strong>A:</strong> This way there is a lower chance of your code breaking if we change something on our end.
|
||||
* For example, if we realized there is a much better way of handling dependency injection we would keep the
|
||||
* interface the same so your code doesn't have to change. Whereas if you were directly referencing
|
||||
* interface the same so your code doesn't have to change. Whereas if you were directly referencing
|
||||
* the concrete object we replaced, there would be issues.
|
||||
*
|
||||
* @author James Seibel
|
||||
@@ -31,10 +31,10 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverri
|
||||
*/
|
||||
public class DhApi
|
||||
{
|
||||
/**
|
||||
* <strong>WARNING:</strong>
|
||||
/**
|
||||
* <strong>WARNING:</strong>
|
||||
* All objects in this class will be null until after DH initializes for the first time. <br><br>
|
||||
*
|
||||
*
|
||||
* Bind a custom {@link DhApiAfterDhInitEvent DhApiAfterDhInitEvent}
|
||||
* to {@link DhApi#events ApiCoreInjectors.events} in order to be notified when this class can
|
||||
* be safely used.
|
||||
@@ -44,8 +44,8 @@ public class DhApi
|
||||
/** Used to interact with Distant Horizons' Configs. */
|
||||
public static IDhApiConfig configs = null;
|
||||
|
||||
/**
|
||||
* Used to interact with Distant Horizons' terrain data.
|
||||
/**
|
||||
* Used to interact with Distant Horizons' terrain data.
|
||||
* Designed to be used in conjunction with {@link DhApi.Delayed#worldProxy}.
|
||||
*/
|
||||
public static IDhApiTerrainDataRepo terrainRepo = null;
|
||||
@@ -81,8 +81,8 @@ public class DhApi
|
||||
/** This version should be updated whenever non-breaking fixes are added to the Distant Horizons API. */
|
||||
public static int getApiPatchVersion() { return ModInfo.API_PATH_VERSION; }
|
||||
|
||||
/**
|
||||
* Returns the mod's semantic version number in the format: Major.Minor.Patch
|
||||
/**
|
||||
* Returns the mod's semantic version number in the format: Major.Minor.Patch
|
||||
* with optional extensions "-a" for alpha, "-b" for beta, and -dev for unstable development builds. <br>
|
||||
* Examples: "1.6.9-a", "1.7.0-a-dev", "2.1.0-b", "3.0.0", "3.1.4-dev"
|
||||
*/
|
||||
|
||||
@@ -9,11 +9,11 @@ package com.seibel.distanthorizons.api.enums;
|
||||
* is, with the smallest being 0 (1 block wide). <br>
|
||||
* The width of a detail level can be calculated by putting the detail level to the power of 2. <br>
|
||||
* Example for the chunk detail level (4): 2^4 = 16 blocks wide <Br><br>
|
||||
*
|
||||
*
|
||||
* This enum doesn't contain all valid detail levels, only those most likely to be needed.
|
||||
* Detail levels 1,2,3, ... 255 are all technically valid detail levels
|
||||
* (although anything beyond {@link EDhApiDetailLevel#REGION} may be difficult deal with).
|
||||
*
|
||||
* Detail levels 1,2,3, ... 255 are all technically valid detail levels
|
||||
* (although anything beyond {@link EDhApiDetailLevel#REGION} may be difficult deal with).
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-12-5
|
||||
*/
|
||||
@@ -23,14 +23,14 @@ public enum EDhApiDetailLevel
|
||||
// when adding items up the API minor version
|
||||
// when removing items up the API major version
|
||||
|
||||
/**
|
||||
/**
|
||||
* detail level: 0 <Br>
|
||||
* width in Blocks: 1
|
||||
* width in Blocks: 1
|
||||
*/
|
||||
BLOCK(0, 1),
|
||||
/**
|
||||
* detail level: 4 <Br>
|
||||
* width in Blocks: 16
|
||||
* width in Blocks: 16
|
||||
*/
|
||||
CHUNK(4, 16),
|
||||
/**
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
* Add this annotation to enum values that
|
||||
* are valid config options, but shouldn't be selectable
|
||||
* when toggling through the options. <br><br>
|
||||
*
|
||||
* Example: A preset's "custom" option shouldn't be selectable
|
||||
*
|
||||
* Example: A preset's "custom" option shouldn't be selectable
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DisallowSelectingViaConfigGui
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ package com.seibel.distanthorizons.api.enums.config;
|
||||
* RARE <br> <br>
|
||||
*
|
||||
* Determines how fast the buffers should be regenerated
|
||||
*
|
||||
*
|
||||
* @author Leonardo Amato
|
||||
* @version 9-25-2021
|
||||
*/
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ package com.seibel.distanthorizons.api.enums.config;
|
||||
*
|
||||
* Determines which LODs should have priority when generating
|
||||
* outside the normal view distance.
|
||||
*
|
||||
*
|
||||
* @author Leonardo Amato
|
||||
* @version 12-1-2021
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@ public enum EGpuUploadMethod
|
||||
{
|
||||
/** Picks the best option based on the GPU the user has. */
|
||||
AUTO(false, false),
|
||||
|
||||
|
||||
// commented out since it isn't currently in use
|
||||
//BUFFER_STORAGE_MAPPING(true, true),
|
||||
|
||||
@@ -43,14 +43,14 @@ public enum EGpuUploadMethod
|
||||
|
||||
/** Fast rendering but may stutter when uploading. */
|
||||
SUB_DATA(false, false),
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* May end up storing buffers in System memory. <br>
|
||||
* Fast rending if in GPU memory, slow if in system memory, <br>
|
||||
* but won't stutter when uploading.
|
||||
* but won't stutter when uploading.
|
||||
*/
|
||||
BUFFER_MAPPING(true, false),
|
||||
|
||||
|
||||
/** Fast rendering but may stutter when uploading. */
|
||||
DATA(false, false);
|
||||
|
||||
|
||||
+2
-2
@@ -52,8 +52,8 @@ public enum EHorizontalQuality
|
||||
|
||||
EHorizontalQuality(double quadraticBase, int distanceUnitInBlocks)
|
||||
{
|
||||
this.quadraticBase = quadraticBase;
|
||||
this.quadraticBase = quadraticBase;
|
||||
this.distanceUnitInBlocks = distanceUnitInBlocks;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.distanthorizons.api.enums.config;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,30 +16,32 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.distanthorizons.api.enums.config;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
public enum ELoggerMode
|
||||
{
|
||||
DISABLED(Level.OFF, Level.OFF),
|
||||
LOG_ALL_TO_FILE(Level.ALL, Level.OFF),
|
||||
LOG_ERROR_TO_CHAT(Level.ALL, Level.ERROR),
|
||||
LOG_WARNING_TO_CHAT(Level.ALL, Level.WARN),
|
||||
LOG_INFO_TO_CHAT(Level.ALL, Level.INFO),
|
||||
LOG_DEBUG_TO_CHAT(Level.ALL, Level.DEBUG),
|
||||
LOG_ALL_TO_CHAT(Level.ALL, Level.ALL),
|
||||
LOG_ERROR_TO_CHAT_AND_FILE(Level.ERROR, Level.ERROR),
|
||||
LOG_WARNING_TO_CHAT_AND_FILE(Level.WARN, Level.WARN),
|
||||
LOG_INFO_TO_CHAT_AND_FILE(Level.INFO, Level.INFO),
|
||||
LOG_DEBUG_TO_CHAT_AND_FILE(Level.DEBUG, Level.DEBUG),
|
||||
LOG_WARNING_TO_CHAT_AND_INFO_TO_FILE(Level.INFO, Level.WARN),
|
||||
LOG_ERROR_TO_CHAT_AND_INFO_TO_FILE(Level.INFO, Level.ERROR),
|
||||
;
|
||||
public final Level levelForFile;
|
||||
public final Level levelForChat;
|
||||
ELoggerMode(Level levelForFile, Level levelForChat) {
|
||||
this.levelForFile = levelForFile;
|
||||
this.levelForChat = levelForChat;
|
||||
}
|
||||
DISABLED(Level.OFF, Level.OFF),
|
||||
LOG_ALL_TO_FILE(Level.ALL, Level.OFF),
|
||||
LOG_ERROR_TO_CHAT(Level.ALL, Level.ERROR),
|
||||
LOG_WARNING_TO_CHAT(Level.ALL, Level.WARN),
|
||||
LOG_INFO_TO_CHAT(Level.ALL, Level.INFO),
|
||||
LOG_DEBUG_TO_CHAT(Level.ALL, Level.DEBUG),
|
||||
LOG_ALL_TO_CHAT(Level.ALL, Level.ALL),
|
||||
LOG_ERROR_TO_CHAT_AND_FILE(Level.ERROR, Level.ERROR),
|
||||
LOG_WARNING_TO_CHAT_AND_FILE(Level.WARN, Level.WARN),
|
||||
LOG_INFO_TO_CHAT_AND_FILE(Level.INFO, Level.INFO),
|
||||
LOG_DEBUG_TO_CHAT_AND_FILE(Level.DEBUG, Level.DEBUG),
|
||||
LOG_WARNING_TO_CHAT_AND_INFO_TO_FILE(Level.INFO, Level.WARN),
|
||||
LOG_ERROR_TO_CHAT_AND_INFO_TO_FILE(Level.INFO, Level.ERROR),
|
||||
;
|
||||
public final Level levelForFile;
|
||||
public final Level levelForChat;
|
||||
ELoggerMode(Level levelForFile, Level levelForChat)
|
||||
{
|
||||
this.levelForFile = levelForFile;
|
||||
this.levelForChat = levelForChat;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
|
||||
* FOUR_BLOCKS <br>
|
||||
* HALF_CHUNK <Br>
|
||||
* CHUNK <br>
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @author Leonardo Amato
|
||||
* @version 2023-6-14
|
||||
|
||||
+4
-4
@@ -27,7 +27,7 @@ package com.seibel.distanthorizons.api.enums.config;
|
||||
* NAME_IP_PORT_MC_VERSION, <br> <br>
|
||||
*
|
||||
* Determines how the multiplayer folders should be named.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-7-1
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ public enum EServerFolderNameMode
|
||||
/** Only use the server name */
|
||||
NAME_ONLY,
|
||||
|
||||
/**
|
||||
/**
|
||||
* {SERVER_NAME} IP {IP} <br>
|
||||
* Example: Minecraft Server IP 192.168.1.40
|
||||
*/
|
||||
@@ -53,10 +53,10 @@ public enum EServerFolderNameMode
|
||||
*/
|
||||
NAME_IP_PORT,
|
||||
|
||||
/**
|
||||
/**
|
||||
* {SERVER_NAME} IP {IP} <br>
|
||||
* Example: Minecraft Server IP 192.168.1.40:25565 GameVersion 1.16.5 <Br> <br>
|
||||
*
|
||||
*
|
||||
* Not normally recommended, since the game version can change if the
|
||||
* server installs paper or some other jar. <br>
|
||||
* This is just here to provide backwards compatibility.
|
||||
|
||||
@@ -26,7 +26,7 @@ package com.seibel.distanthorizons.api.enums.config;
|
||||
*
|
||||
* This represents how far the LODs should overlap with
|
||||
* the vanilla Minecraft terrain.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-6-30
|
||||
*/
|
||||
|
||||
@@ -33,11 +33,11 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
|
||||
*/
|
||||
public enum EVerticalQuality
|
||||
{
|
||||
HEIGHT_MAP(new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }),
|
||||
LOW(new int[] { 4, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1 }),
|
||||
MEDIUM(new int[] { 6, 4, 3, 2, 2, 1, 1, 1, 1, 1, 1 }),
|
||||
HIGH(new int[] { 8, 6, 4, 2, 2, 2, 2, 1, 1, 1, 1 }),
|
||||
EXTREME(new int[] { 16, 8, 4, 2, 2, 2, 2, 1, 1, 1, 1 });
|
||||
HEIGHT_MAP(new int[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
|
||||
LOW(new int[]{4, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1}),
|
||||
MEDIUM(new int[]{6, 4, 3, 2, 2, 1, 1, 1, 1, 1, 1}),
|
||||
HIGH(new int[]{8, 6, 4, 2, 2, 2, 2, 1, 1, 1, 1}),
|
||||
EXTREME(new int[]{16, 8, 4, 2, 2, 2, 2, 1, 1, 1, 1});
|
||||
|
||||
/** represents how many LODs can be rendered in a single vertical slice */
|
||||
public final int[] maxVerticalData;
|
||||
@@ -48,11 +48,11 @@ public enum EVerticalQuality
|
||||
|
||||
|
||||
|
||||
public int calculateMaxVerticalData(byte dataDetail)
|
||||
public int calculateMaxVerticalData(byte dataDetail)
|
||||
{
|
||||
// for detail levels lower than what the enum defines, use the lowest quality item
|
||||
int index = MathUtil.clamp(0, dataDetail, this.maxVerticalData.length - 1);
|
||||
return this.maxVerticalData[index];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui
|
||||
|
||||
/**
|
||||
* CUSTOM, <br><br>
|
||||
*
|
||||
*
|
||||
* MINIMUM, <br>
|
||||
* LOW, <br>
|
||||
* MEDIUM, <br>
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui
|
||||
|
||||
/**
|
||||
* CUSTOM, <br><br>
|
||||
*
|
||||
*
|
||||
* MINIMAL_IMPACT, <br>
|
||||
* LOW_IMPACT, <br>
|
||||
* BALANCED, <br>
|
||||
|
||||
+25
-15
@@ -53,27 +53,37 @@ public enum EDebugRendering
|
||||
SHOW_RENDER_SOURCE_FLAG;
|
||||
|
||||
|
||||
public static EDebugRendering next(EDebugRendering type)
|
||||
public static EDebugRendering next(EDebugRendering type)
|
||||
{
|
||||
switch (type)
|
||||
switch (type)
|
||||
{
|
||||
case OFF: return SHOW_DETAIL;
|
||||
case SHOW_DETAIL: return SHOW_GENMODE;
|
||||
case SHOW_GENMODE: return SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS: return SHOW_RENDER_SOURCE_FLAG;
|
||||
default: return OFF;
|
||||
case OFF:
|
||||
return SHOW_DETAIL;
|
||||
case SHOW_DETAIL:
|
||||
return SHOW_GENMODE;
|
||||
case SHOW_GENMODE:
|
||||
return SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS:
|
||||
return SHOW_RENDER_SOURCE_FLAG;
|
||||
default:
|
||||
return OFF;
|
||||
}
|
||||
}
|
||||
|
||||
public static EDebugRendering previous(EDebugRendering type)
|
||||
|
||||
public static EDebugRendering previous(EDebugRendering type)
|
||||
{
|
||||
switch (type)
|
||||
switch (type)
|
||||
{
|
||||
case OFF: return SHOW_RENDER_SOURCE_FLAG;
|
||||
case SHOW_RENDER_SOURCE_FLAG: return SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS: return SHOW_GENMODE;
|
||||
case SHOW_GENMODE: return SHOW_DETAIL;
|
||||
default: return OFF;
|
||||
case OFF:
|
||||
return SHOW_RENDER_SOURCE_FLAG;
|
||||
case SHOW_RENDER_SOURCE_FLAG:
|
||||
return SHOW_OVERLAPPING_QUADS;
|
||||
case SHOW_OVERLAPPING_QUADS:
|
||||
return SHOW_GENMODE;
|
||||
case SHOW_GENMODE:
|
||||
return SHOW_DETAIL;
|
||||
default:
|
||||
return OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
|
||||
/**
|
||||
* USE_DEFAULT_FOG_COLOR, <br>
|
||||
* USE_SKY_COLOR, <br>
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-6-9
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
|
||||
|
||||
/**
|
||||
* NEAR, FAR, or NEAR_AND_FAR.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-6-2
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
|
||||
* USE_OPTIFINE_FOG_SETTING, <br>
|
||||
* FOG_ENABLED, <br>
|
||||
* FOG_DISABLED <br>
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-6-2
|
||||
*/
|
||||
|
||||
+11
-11
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.distanthorizons.api.enums.rendering;
|
||||
|
||||
/**
|
||||
@@ -36,14 +36,14 @@ package com.seibel.distanthorizons.api.enums.rendering;
|
||||
*/
|
||||
public enum EHeightFogMixMode
|
||||
{
|
||||
BASIC,
|
||||
IGNORE_HEIGHT,
|
||||
ADDITION,
|
||||
MAX,
|
||||
MULTIPLY,
|
||||
INVERSE_MULTIPLY,
|
||||
LIMITED_ADDITION,
|
||||
MULTIPLY_ADDITION,
|
||||
INVERSE_MULTIPLY_ADDITION,
|
||||
AVERAGE,
|
||||
BASIC,
|
||||
IGNORE_HEIGHT,
|
||||
ADDITION,
|
||||
MAX,
|
||||
MULTIPLY,
|
||||
INVERSE_MULTIPLY,
|
||||
LIMITED_ADDITION,
|
||||
MULTIPLY_ADDITION,
|
||||
INVERSE_MULTIPLY_ADDITION,
|
||||
AVERAGE,
|
||||
}
|
||||
|
||||
+39
-33
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.distanthorizons.api.enums.rendering;
|
||||
|
||||
/**
|
||||
@@ -28,36 +28,42 @@ package com.seibel.distanthorizons.api.enums.rendering;
|
||||
*/
|
||||
public enum ERendererMode
|
||||
{
|
||||
// Reminder:
|
||||
// when adding items up the API minor version
|
||||
// when removing items up the API major version
|
||||
|
||||
|
||||
DEFAULT,
|
||||
DEBUG,
|
||||
DISABLED;
|
||||
|
||||
|
||||
/** Used by the config GUI to cycle through the available rendering options */
|
||||
public static ERendererMode next(ERendererMode type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DEFAULT: return DEBUG;
|
||||
case DEBUG: return DISABLED;
|
||||
default: return DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
/** Used by the config GUI to cycle through the available rendering options */
|
||||
public static ERendererMode previous(ERendererMode type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DEFAULT: return DISABLED;
|
||||
case DEBUG: return DEFAULT;
|
||||
default: return DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
// Reminder:
|
||||
// when adding items up the API minor version
|
||||
// when removing items up the API major version
|
||||
|
||||
|
||||
DEFAULT,
|
||||
DEBUG,
|
||||
DISABLED;
|
||||
|
||||
|
||||
/** Used by the config GUI to cycle through the available rendering options */
|
||||
public static ERendererMode next(ERendererMode type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DEFAULT:
|
||||
return DEBUG;
|
||||
case DEBUG:
|
||||
return DISABLED;
|
||||
default:
|
||||
return DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
/** Used by the config GUI to cycle through the available rendering options */
|
||||
public static ERendererMode previous(ERendererMode type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DEFAULT:
|
||||
return DISABLED;
|
||||
case DEBUG:
|
||||
return DEFAULT;
|
||||
default:
|
||||
return DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ public enum ETransparency
|
||||
DISABLED(false, false),
|
||||
FAKE(true, true),
|
||||
COMPLETE(true, false);
|
||||
|
||||
|
||||
public final boolean transparencyEnabled;
|
||||
public final boolean fakeTransparencyEnabled;
|
||||
|
||||
|
||||
ETransparency(boolean transparencyEnabled, boolean fakeTransparencyEnabled)
|
||||
{
|
||||
this.transparencyEnabled = transparencyEnabled;
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ package com.seibel.distanthorizons.api.enums.worldGeneration;
|
||||
* FULL <br><br>
|
||||
*
|
||||
* In order of fastest to slowest.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @author Leonardo Amato
|
||||
* @version 2022-12-10
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.seibel.distanthorizons.api.interfaces;
|
||||
/**
|
||||
* Implemented by wrappers so developers can
|
||||
* access the underlying Minecraft object(s).
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-17
|
||||
*/
|
||||
|
||||
+2
-1
@@ -23,11 +23,12 @@ import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
|
||||
|
||||
/**
|
||||
* A Minecraft version independent way of handling Biomes.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
public interface IDhApiBiomeWrapper extends IDhApiUnsafeWrapper
|
||||
{
|
||||
String getName();
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@ import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
|
||||
|
||||
/**
|
||||
* A Minecraft version independent way of handling Blocks.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-11
|
||||
*/
|
||||
public interface IDhApiBlockStateWrapper extends IDhApiUnsafeWrapper
|
||||
{
|
||||
boolean isAir();
|
||||
boolean isAir();
|
||||
|
||||
boolean isSolid();
|
||||
boolean isLiquid();
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.seibel.distanthorizons.api.interfaces.config.client.*;
|
||||
/**
|
||||
* This interfaces holds all config groups
|
||||
* the API has access to for easy access.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-14
|
||||
*/
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
|
||||
/**
|
||||
* This interface is just used to organize API config groups so
|
||||
* they can be more easily handled together.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 9-15-2022
|
||||
*/
|
||||
|
||||
-1
@@ -4,7 +4,6 @@ package com.seibel.distanthorizons.api.interfaces.config;
|
||||
* An interface for Distant Horizon's Config.
|
||||
*
|
||||
* @param <T> The data type of this config.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-9-15
|
||||
*/
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public interface IDhApiWorldGenerationConfig extends IDhApiConfigGroup
|
||||
/** Defines to what level LOD chunks will be generated. */
|
||||
IDhApiConfigValue<EDhApiDistantGeneratorMode> distantGeneratorMode();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Defines what lighting engine will be used when
|
||||
* Distant Horizons generates chunks.
|
||||
*/
|
||||
|
||||
+3
-3
@@ -144,9 +144,9 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
|
||||
/** If enabled vanilla chunk rendering is disabled and only fake chunks are rendered. */
|
||||
IDhApiConfigValue<Boolean> lodOnlyMode();
|
||||
|
||||
/**
|
||||
* Setting this to a non-zero number will modify vanilla Minecraft's LOD Bias,
|
||||
* increasing how quickly its textures fade away.
|
||||
/**
|
||||
* Setting this to a non-zero number will modify vanilla Minecraft's LOD Bias,
|
||||
* increasing how quickly its textures fade away.
|
||||
*/
|
||||
IDhApiConfigValue<Double> lodBias();
|
||||
|
||||
|
||||
+2
-2
@@ -46,9 +46,9 @@ public interface IDhApiMultiThreadingConfig extends IDhApiConfigGroup
|
||||
/** Defines how many file handler threads are used. */
|
||||
IDhApiConfigValue<Integer> fileHandlerThreads();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Defines how many Full to Render data converter threads are used. <br><br>
|
||||
*
|
||||
*
|
||||
* <strong>Full data</strong> - Distant Horizons data based on BlockState and Biome IDs <br>
|
||||
* <strong>Render data</strong> - color data used when Distant Horizons is rendering
|
||||
*/
|
||||
|
||||
+15
-15
@@ -9,7 +9,7 @@ import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint;
|
||||
|
||||
/**
|
||||
* Used to interface with Distant Horizons' terrain data.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-22
|
||||
*/
|
||||
@@ -25,9 +25,9 @@ public interface IDhApiTerrainDataRepo
|
||||
/** Returns every datapoint in the column located at the given block X and Z position top to bottom. */
|
||||
DhApiResult<DhApiTerrainDataPoint[]> getColumnDataAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosZ);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns every datapoint in the given chunk's X and Z position. <br><br>
|
||||
*
|
||||
*
|
||||
* The returned array is ordered: [relativeBlockX][relativeBlockZ][columnIndex] <br>
|
||||
* RelativeBlockX/Z are relative to the block position closest to negative infinity in the chunk's position. <br>
|
||||
* The column data is ordered from top to bottom. Note: each column may have a different number of values. <br>
|
||||
@@ -46,21 +46,22 @@ public interface IDhApiTerrainDataRepo
|
||||
/**
|
||||
* Returns every datapoint in the column located at the given detail level and X/Z position. <br>
|
||||
* This can be used to return terrain data for non-standard sizes (IE 2x2 blocks or 2x2 chunks).
|
||||
*
|
||||
*
|
||||
* @param detailLevel a positive byte defining the detail level of the returned data. <br>
|
||||
* Every increase doubles the width of the returned area. <br>
|
||||
* Example values: 0 = block, 1 = 2x2 blocks, 2 = 4x4 blocks, ... 4 = chunk (16x16 blocks), ... 9 = region (512x512 blocks) <br>
|
||||
* See {@link EDhApiDetailLevel} for more information.
|
||||
* Every increase doubles the width of the returned area. <br>
|
||||
* Example values: 0 = block, 1 = 2x2 blocks, 2 = 4x4 blocks, ... 4 = chunk (16x16 blocks), ... 9 = region (512x512 blocks) <br>
|
||||
* See {@link EDhApiDetailLevel} for more information.
|
||||
*/
|
||||
DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtDetailLevelAndPos(IDhApiLevelWrapper levelWrapper, byte detailLevel, int posX, int posZ);
|
||||
|
||||
/**
|
||||
* Returns the datapoint and position of the LOD
|
||||
* at the end of the given ray. <br><br>
|
||||
*
|
||||
*
|
||||
* Will return "success" with a null datapoint if the ray reaches the max length without finding any data.
|
||||
*/
|
||||
DhApiResult<DhApiRaycastResult> raycast(IDhApiLevelWrapper levelWrapper,
|
||||
DhApiResult<DhApiRaycastResult> raycast(
|
||||
IDhApiLevelWrapper levelWrapper,
|
||||
double rayOriginX, double rayOriginY, double rayOriginZ,
|
||||
float rayDirectionX, float rayDirectionY, float rayDirectionZ,
|
||||
int maxRayBlockLength);
|
||||
@@ -73,19 +74,18 @@ public interface IDhApiTerrainDataRepo
|
||||
|
||||
/**
|
||||
* Sets the LOD data for the given chunk at the chunk's position. <br><br>
|
||||
*
|
||||
*
|
||||
* Notes: <br>
|
||||
* - Only works if the given {@link IDhApiLevelWrapper} points to a loaded level. <br>
|
||||
* - If the player travels to this chunk, or the chunk is updated in some other way; your data will be replaced
|
||||
* by whatever the current chunk is. <br>
|
||||
* by whatever the current chunk is. <br>
|
||||
* - This method may not update the LOD data immediately. Any other chunks have
|
||||
* been queued to update, they will be handled first.
|
||||
* been queued to update, they will be handled first.
|
||||
*
|
||||
* @param levelWrapper the level wrapper that the chunk should be saved to.
|
||||
* @param chunkObjectArray see {@link IDhApiWorldGenerator#generateChunks} for what objects are expected.
|
||||
*
|
||||
* @throws ClassCastException if chunkObjectArray doesn't contain the right objects.
|
||||
* The exception will contain the expected object(s).
|
||||
* @throws ClassCastException if chunkObjectArray doesn't contain the right objects.
|
||||
* The exception will contain the expected object(s).
|
||||
*/
|
||||
public DhApiResult<Void> overwriteChunkDataAsync(IDhApiLevelWrapper levelWrapper, Object[] chunkObjectArray) throws ClassCastException;
|
||||
|
||||
|
||||
+2
-2
@@ -34,8 +34,8 @@ public interface IDhApiEventInjector extends IDependencyInjector<IDhApiEvent>
|
||||
/**
|
||||
* Unlinks the given event handler, preventing the handler from being called in the future.
|
||||
*
|
||||
* @throws IllegalArgumentException if the implementation object doesn't implement the interface
|
||||
* @return true if the handler was unbound, false if the handler wasn't bound.
|
||||
* @throws IllegalArgumentException if the implementation object doesn't implement the interface
|
||||
*/
|
||||
// Note to self: Don't try adding a generic type to IDhApiEvent, the constructor won't accept it
|
||||
boolean unbind(Class<? extends IDhApiEvent> dependencyInterface, Class<? extends IDhApiEvent> dependencyClassToRemove) throws IllegalArgumentException;
|
||||
@@ -46,8 +46,8 @@ public interface IDhApiEventInjector extends IDependencyInjector<IDhApiEvent>
|
||||
*
|
||||
* @param abstractEvent event type
|
||||
* @param eventParameterObject event parameter
|
||||
* @return if any of bound event handlers returned that this event should be canceled.
|
||||
* @param <T> the parameter type taken by the event handlers.
|
||||
* @return if any of bound event handlers returned that this event should be canceled.
|
||||
*/
|
||||
<T, U extends IDhApiEvent<T>> boolean fireAllEvents(Class<U> abstractEvent, T eventParameterObject);
|
||||
|
||||
|
||||
+5
-5
@@ -46,9 +46,9 @@ public abstract class AbstractDhApiChunkWorldGenerator implements Closeable, IDh
|
||||
// TODO what does this mean?
|
||||
int genChunkWidth = BitShiftUtil.powerOfTwo(granularity - 4);
|
||||
|
||||
for (int chunkX = chunkPosMinX; chunkX < chunkPosMinX+genChunkWidth; chunkX++)
|
||||
for (int chunkX = chunkPosMinX; chunkX < chunkPosMinX + genChunkWidth; chunkX++)
|
||||
{
|
||||
for (int chunkZ = chunkPosMinZ; chunkZ< chunkPosMinZ+genChunkWidth; chunkZ++)
|
||||
for (int chunkZ = chunkPosMinZ; chunkZ < chunkPosMinZ + genChunkWidth; chunkZ++)
|
||||
{
|
||||
Object[] rawMcObjectArray = this.generateChunk(chunkX, chunkZ, generatorMode);
|
||||
resultConsumer.accept(rawMcObjectArray);
|
||||
@@ -60,10 +60,10 @@ public abstract class AbstractDhApiChunkWorldGenerator implements Closeable, IDh
|
||||
/**
|
||||
* This method is called to generate terrain over a given area
|
||||
* from a thread defined by Distant Horizons. <br><br>
|
||||
*
|
||||
* See {@link IDhApiWorldGenerator#generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer) IDhApiWorldGenerator.generateChunks}
|
||||
*
|
||||
* See {@link IDhApiWorldGenerator#generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer) IDhApiWorldGenerator.generateChunks}
|
||||
* for the list of Object's this method should return along with additional documentation.
|
||||
*
|
||||
*
|
||||
* @see IDhApiWorldGenerator#generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer) IDhApiWorldGenerator#generateChunks
|
||||
*/
|
||||
public abstract Object[] generateChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode);
|
||||
|
||||
+16
-15
@@ -30,10 +30,10 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
|
||||
* Minimum detail level is 0 (1 block) <br>
|
||||
* Default detail level is 0 <br>
|
||||
* For more information on what detail levels represent see: {@link EDhApiDetailLevel}. <br><br>
|
||||
*
|
||||
*
|
||||
* TODO: System currently only supports 1x1 block per data.
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*/
|
||||
default byte getSmallestDataDetailLevel() { return EDhApiDetailLevel.BLOCK.detailLevel; }
|
||||
/**
|
||||
@@ -41,32 +41,32 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
|
||||
* Minimum detail level is 0 (1 block) <br>
|
||||
* Default detail level is 0 <br>
|
||||
* For more information on what detail levels represent see: {@link EDhApiDetailLevel}.
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*/
|
||||
default byte getLargestDataDetailLevel() { return EDhApiDetailLevel.BLOCK.detailLevel; }
|
||||
|
||||
/**
|
||||
* When creating generation requests the system will attempt to group nearby tasks together. <br><br>
|
||||
* What is the minimum size a single generation call can batch together? <br>
|
||||
*
|
||||
*
|
||||
* Minimum detail level is 4 (the size of a MC chunk) <br>
|
||||
* Default detail level is 4 <br>
|
||||
* For more information on what detail levels represent see: {@link EDhApiDetailLevel}.
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*/
|
||||
default byte getMinGenerationGranularity() { return EDhApiDetailLevel.CHUNK.detailLevel; }
|
||||
|
||||
/**
|
||||
* When creating generation requests the system will attempt to group nearby tasks together. <br><br>
|
||||
* What is the maximum size a single generation call can batch together? <br>
|
||||
*
|
||||
*
|
||||
* Minimum detail level is 4 (the size of a MC chunk) <br>
|
||||
* Default detail level is 6 (4x4 chunks) <br>
|
||||
* For more information on what detail levels represent see: {@link EDhApiDetailLevel}.
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*
|
||||
* @see EDhApiDetailLevel
|
||||
*/
|
||||
default byte getMaxGenerationGranularity() { return (byte) (EDhApiDetailLevel.CHUNK.detailLevel + 2); }
|
||||
|
||||
@@ -82,19 +82,20 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
|
||||
|
||||
/**
|
||||
* This method is called by Distant Horizons to generate terrain over a given area. <br><br>
|
||||
*
|
||||
* After a chunk has been generated it (and any necessary supporting objects as listed below) should be passed into the
|
||||
*
|
||||
* After a chunk has been generated it (and any necessary supporting objects as listed below) should be passed into the
|
||||
* resultConsumer's {@link Consumer#accept} method. If the Consumer is given the wrong data
|
||||
* type(s) it will disable the world generator and log an error with a list of objects it was expecting. <br>
|
||||
* <strong>Note:</strong> these objects are minecraft version dependent and will change without notice!
|
||||
* Please run your generator in game at least once to confirm the objects you are returning are correct. <br><br>
|
||||
*
|
||||
*
|
||||
* Consumer expected inputs for each minecraft version (in order): <br>
|
||||
* <strong>1.18:</strong> [net.minecraft.world.level.chunk.ChunkAccess] and [net.minecraft.world.level.LevelReader] <br>
|
||||
* <strong>1.19:</strong> [net.minecraft.world.level.chunk.ChunkAccess] and [net.minecraft.world.level.LevelReader] <br>
|
||||
* <strong>1.20:</strong> [net.minecraft.world.level.chunk.ChunkAccess] and [net.minecraft.world.level.LevelReader] <br>
|
||||
*/
|
||||
CompletableFuture<Void> generateChunks(int chunkPosMinX, int chunkPosMinZ,
|
||||
CompletableFuture<Void> generateChunks(
|
||||
int chunkPosMinX, int chunkPosMinZ,
|
||||
byte granularity, byte targetDataDetail, EDhApiDistantGeneratorMode generatorMode,
|
||||
ExecutorService worldGeneratorThreadPool, Consumer<Object[]> resultConsumer);
|
||||
|
||||
|
||||
+5
-5
@@ -23,24 +23,24 @@ import com.seibel.distanthorizons.api.objects.DhApiResult;
|
||||
|
||||
/**
|
||||
* Used to interact with Distant Horizons' rendering system.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-2-8
|
||||
*/
|
||||
public interface IDhApiRenderProxy
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Forces any cached render data to be deleted and regenerated.
|
||||
* This is generally called whenever resource packs are changed or specific
|
||||
* rendering settings are changed in Distant Horizon's config. <Br><Br>
|
||||
*
|
||||
*
|
||||
* If this is called on a dedicated server it won't do anything and will return {@link DhApiResult#success} = false <Br><Br>
|
||||
*
|
||||
*
|
||||
* Background: <Br>
|
||||
* Distant Horizons has two different file formats: Full data and Render data. <Br>
|
||||
* - Full data files store the block, biome, etc. information and is the result of loading or generating new chunks. <Br>
|
||||
* - Render data files store LOD colors and are created using the Full data and currently loaded resource packs. <Br>
|
||||
* This is the data cleared by this method.
|
||||
* This is the data cleared by this method.
|
||||
*/
|
||||
DhApiResult<Boolean> clearRenderDataCache();
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
||||
/**
|
||||
* Can be either a Server or Client level.<br>
|
||||
* A level is equivalent to a dimension in vanilla Minecraft.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-7-14
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ public interface IDhApiLevelWrapper extends IDhApiUnsafeWrapper
|
||||
/** Returns the max block height of the level(?) */
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the lowest possible block position for the level. <br>
|
||||
* For MC versions before 1.18 this will return 0.
|
||||
*/
|
||||
|
||||
+7
-7
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.api.interfaces.world;
|
||||
/**
|
||||
* Used to interact with Distant Horizons' current world. <br>
|
||||
* A world is equivalent to a single server connection or a singleplayer world.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-20
|
||||
*/
|
||||
@@ -32,10 +32,10 @@ public interface IDhApiWorldProxy
|
||||
boolean worldLoaded();
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* In singleplayer this will return the level the player is currently in. <br>
|
||||
* In multiplayer this will return null.
|
||||
*
|
||||
*
|
||||
* @throws IllegalStateException if no world is loaded
|
||||
*/
|
||||
IDhApiLevelWrapper getSinglePlayerLevel() throws IllegalStateException;
|
||||
@@ -43,18 +43,18 @@ public interface IDhApiWorldProxy
|
||||
/** @throws IllegalStateException if no world is loaded */
|
||||
Iterable<IDhApiLevelWrapper> getAllLoadedLevelWrappers() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
/**
|
||||
* In the case of servers running multiverse there may be multiple levels for the same dimensionType.
|
||||
*
|
||||
* @throws IllegalStateException if no world is loaded
|
||||
* @throws IllegalStateException if no world is loaded
|
||||
*/
|
||||
Iterable<IDhApiLevelWrapper> getAllLoadedLevelsForDimensionType(IDhApiDimensionTypeWrapper dimensionTypeWrapper) throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Returns any dimensions that have names containing the given string (case-insensitive). <br>
|
||||
* In the case of servers running multiverse there may be multiple levels for the same dimensionType.
|
||||
* In the case of servers running multiverse there may be multiple levels for the same dimensionType.
|
||||
*
|
||||
* @throws IllegalStateException if no world is loaded
|
||||
* @throws IllegalStateException if no world is loaded
|
||||
*/
|
||||
Iterable<IDhApiLevelWrapper> getAllLoadedLevelsWithDimensionNameLike(String dimensionName) throws IllegalStateException;
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class DhApiEventRegister
|
||||
return DhApiResult.createFail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregisters the given event handler for this event if one has been registered. <br>
|
||||
* If no eventHandler of the given class has been registered the result will return
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
|
||||
/**
|
||||
* Fired after Distant Horizons finishes running its setup.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
*/
|
||||
|
||||
+3
-2
@@ -8,10 +8,10 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
* Fired after Distant Horizons finishes rendering a frame. <br>
|
||||
* At this point DH will have also finished cleaning up any modifications it
|
||||
* did to the OpenGL state, so the state should be back to Minecraft's defaults.
|
||||
*
|
||||
* @see DhApiRenderParam
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
* @see DhApiRenderParam
|
||||
*/
|
||||
public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiAfterRenderEvent.EventParam>
|
||||
{
|
||||
@@ -37,6 +37,7 @@ public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiAfterRen
|
||||
{
|
||||
super(parent.mcProjectionMatrix, parent.mcModelViewMatrix, parent.dhProjectionMatrix, parent.dhModelViewMatrix, parent.partialTicks);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
/**
|
||||
* Fired before Distant Horizons starts running its mod loader setup. <br>
|
||||
* IE this is called before Forge's initClient/initServer or Fabric's init method.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
*/
|
||||
|
||||
+2
-1
@@ -7,7 +7,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
/**
|
||||
* Called before Distant Horizons starts rendering a frame. <br>
|
||||
* Canceling the event will prevent DH from rendering that frame.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
*/
|
||||
@@ -35,6 +35,7 @@ public abstract class DhApiBeforeRenderEvent implements IDhApiCancelableEvent<Dh
|
||||
{
|
||||
super(parent.mcProjectionMatrix, parent.mcModelViewMatrix, parent.dhProjectionMatrix, parent.dhModelViewMatrix, parent.partialTicks);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+6
-5
@@ -10,10 +10,10 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
* that a Minecraft chunk has been modified. <br>
|
||||
* By the time this event has been fired, the chunk modification should have propagated
|
||||
* to DH's full data source, but may not have been updated in the render data source.
|
||||
*
|
||||
* @see IDhApiTerrainDataRepo
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
* @see IDhApiTerrainDataRepo
|
||||
*/
|
||||
public abstract class DhApiChunkModifiedEvent implements IDhApiEvent<DhApiChunkModifiedEvent.EventParam>
|
||||
{
|
||||
@@ -41,15 +41,16 @@ public abstract class DhApiChunkModifiedEvent implements IDhApiEvent<DhApiChunkM
|
||||
/** the modified chunk's X pos in chunk coordinates */
|
||||
public final int chunkX;
|
||||
/** the modified chunk's Z pos in chunk coordinates */
|
||||
public final int chunkZ;
|
||||
public final int chunkZ;
|
||||
|
||||
|
||||
public EventParam(IDhApiLevelWrapper newLevelWrapper, int chunkX, int chunkZ)
|
||||
public EventParam(IDhApiLevelWrapper newLevelWrapper, int chunkX, int chunkZ)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -7,7 +7,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
/**
|
||||
* Called after Distant Horizons finishes loading a new level. <br>
|
||||
* Note: this may be fired before Minecraft has loaded in the player.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
*/
|
||||
@@ -35,6 +35,7 @@ public abstract class DhApiLevelLoadEvent implements IDhApiEvent<DhApiLevelLoadE
|
||||
public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -7,7 +7,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
|
||||
|
||||
/**
|
||||
* Called after Distant Horizons has finished unloading a level.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
*/
|
||||
@@ -35,6 +35,7 @@ public abstract class DhApiLevelUnloadEvent implements IDhApiEvent<DhApiLevelUnl
|
||||
public final IDhApiLevelWrapper levelWrapper;
|
||||
|
||||
public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+6
-6
@@ -3,7 +3,7 @@ package com.seibel.distanthorizons.api.methods.events.interfaces;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiCancelableEventParam;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
|
||||
|
||||
/**
|
||||
/**
|
||||
* If a {@link IDhApiEvent} implements this interface than the event
|
||||
* can be canceled via the {@link DhApiCancelableEventParam#cancelEvent()} method.
|
||||
*
|
||||
@@ -17,13 +17,13 @@ public interface IDhApiCancelableEvent<T> extends IDhApiEvent<T>
|
||||
|
||||
/**
|
||||
* <strong> Shouldn't be called. </strong> <br><br>
|
||||
*
|
||||
*
|
||||
* The {@link IDhApiCancelableEvent#fireEvent(DhApiCancelableEventParam)} method should be used instead.
|
||||
* This override method is present to prevent API users from having to implement it themselves.
|
||||
*
|
||||
*
|
||||
* @deprecated marked as deprecated to warn that this method shouldn't be used. <br>
|
||||
* <strong>DH Internal Note:</strong> Is there a better way to format the {@link IDhApiEvent} classes so we don't need this method?
|
||||
* It would be better to completely hide this method so it isn't possible to accidentally call.
|
||||
* <strong>DH Internal Note:</strong> Is there a better way to format the {@link IDhApiEvent} classes so we don't need this method?
|
||||
* It would be better to completely hide this method so it isn't possible to accidentally call.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
@@ -31,7 +31,7 @@ public interface IDhApiCancelableEvent<T> extends IDhApiEvent<T>
|
||||
{
|
||||
if (!input.getClass().isAssignableFrom(DhApiCancelableEventParam.class))
|
||||
{
|
||||
throw new IllegalArgumentException("Programmer error. ["+IDhApiCancelableEvent.class.getSimpleName()+"] was given a ["+DhApiEventParam.class.getSimpleName()+"] when it should only be given a ["+DhApiCancelableEventParam.class.getSimpleName()+"].");
|
||||
throw new IllegalArgumentException("Programmer error. [" + IDhApiCancelableEvent.class.getSimpleName() + "] was given a [" + DhApiEventParam.class.getSimpleName() + "] when it should only be given a [" + DhApiCancelableEventParam.class.getSimpleName() + "].");
|
||||
}
|
||||
|
||||
this.fireEvent((DhApiCancelableEventParam<T>) input);
|
||||
|
||||
+1
-2
@@ -5,9 +5,8 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
|
||||
|
||||
/**
|
||||
* The interface used by all DH Api events.
|
||||
*
|
||||
*
|
||||
* @param <T> This is the datatype that will be passed into the event handler's method.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2023-6-23
|
||||
*/
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.seibel.distanthorizons.api.methods.events.interfaces;
|
||||
/**
|
||||
* If a {@link IDhApiEvent} implements this interface then the event will only ever be fired once. <Br>
|
||||
* An example of this would be initial setup methods, DH won't run its initial setup more than once. <br><br>
|
||||
*
|
||||
*
|
||||
* If a handler is bound to a one time event after the event has been fired, the handler will immediately fire.
|
||||
*/
|
||||
public interface IDhApiOneTimeEvent<T> extends IDhApiEvent<T>
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ public interface IDhServerMessageReceived<T> extends IDhApiEvent<T>
|
||||
{
|
||||
/**
|
||||
* Triggered when a plugin message is received from the server.
|
||||
*
|
||||
* @param channel The name of the channel this was received on.
|
||||
* @param message The message sent from the server.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/**
|
||||
* Holds objects and methods for listening to events fired by Distant Horizons'.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.api.methods.events;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class DhApiWorldGeneratorOverrideRegister implements IDhApiWorldGenerator
|
||||
{
|
||||
public static DhApiWorldGeneratorOverrideRegister INSTANCE = new DhApiWorldGeneratorOverrideRegister();
|
||||
|
||||
private DhApiWorldGeneratorOverrideRegister() { }
|
||||
private DhApiWorldGeneratorOverrideRegister() { }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/**
|
||||
* The override api package holds objects and methods for overriding Distant Horizons' backend systems, so they can be replaced or improved.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.api.methods.override;
|
||||
|
||||
@@ -2,9 +2,8 @@ package com.seibel.distanthorizons.api.objects;
|
||||
|
||||
/**
|
||||
* Allows for more descriptive non-critical failure states.
|
||||
*
|
||||
* @param <T> The payload type this result contains, can be Void if the result is just used to notify success/failure.
|
||||
*
|
||||
*
|
||||
* @param <T> The payload type this result contains, can be Void if the result is just used to notify success/failure.
|
||||
* @author James Seibel
|
||||
* @version 2022-11-24
|
||||
*/
|
||||
@@ -19,9 +18,9 @@ public class DhApiResult<T>
|
||||
*/
|
||||
public final String message;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Whatever object the API Method generated/returned. <br>
|
||||
* Will be null/Void if this result is just used to notify success/failure.
|
||||
* Will be null/Void if this result is just used to notify success/failure.
|
||||
*/
|
||||
public final T payload;
|
||||
|
||||
@@ -33,7 +32,7 @@ public class DhApiResult<T>
|
||||
{
|
||||
this.success = success;
|
||||
// don't allow null messages, in the case of a null message return the empty string to prevent potential null pointers
|
||||
this.message = (message == null) ? "" : message;
|
||||
this.message = (message == null) ? "" : message;
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.seibel.distanthorizons.coreapi.util.converters.DefaultConverter;
|
||||
*
|
||||
* @param <apiType> The datatype you, an API dev will use.
|
||||
* @param <coreType> The datatype Distant Horizons uses in the background; implementing developers can ignore this.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-6-30
|
||||
*/
|
||||
|
||||
+3
-3
@@ -6,15 +6,15 @@ import com.seibel.distanthorizons.coreapi.util.math.Vec3i;
|
||||
/**
|
||||
* Holds a single datapoint of terrain data
|
||||
* and the block position from the raycast.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-19
|
||||
*/
|
||||
public class DhApiRaycastResult
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* LOD position of this raycast. <br><br>
|
||||
*
|
||||
*
|
||||
* <strong>Note: </strong>
|
||||
* This will NOT be the exact block position if the LOD the ray
|
||||
* hits is more than one block tall. In that case this will
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||
|
||||
/**
|
||||
* Holds a single datapoint of terrain data.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-13
|
||||
*/
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
package com.seibel.distanthorizons.api.objects.math;
|
||||
|
||||
/**
|
||||
* Often used to store block positions or any other
|
||||
* Often used to store block positions or any other
|
||||
* position in 3D space.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-19
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* <strong> Start Here </strong> <br>
|
||||
* {@link com.seibel.distanthorizons.api.DhApi} has almost every method you would want. <br><br>
|
||||
*
|
||||
*
|
||||
* This package contains every method and object that is safe to use within the API.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.api;
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements
|
||||
private ApiEventInjector() { super(IDhApiEvent.class, true); }
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void bind(Class<? extends IDhApiEvent> abstractEvent, IDhApiEvent eventImplementation) throws IllegalStateException, IllegalArgumentException
|
||||
@@ -76,7 +76,7 @@ public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements
|
||||
{
|
||||
// make sure the given dependency implements the necessary interfaces
|
||||
boolean implementsInterface = this.checkIfClassImplements(eventClassToRemove, abstractEvent) ||
|
||||
this.checkIfClassExtends(eventClassToRemove, abstractEvent);
|
||||
this.checkIfClassExtends(eventClassToRemove, abstractEvent);
|
||||
boolean implementsBindable = this.checkIfClassImplements(eventClassToRemove, this.bindableInterface);
|
||||
|
||||
// display any errors
|
||||
@@ -95,7 +95,7 @@ public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements
|
||||
{
|
||||
ArrayList<IDhApiEvent> dependencyList = this.dependencies.get(abstractEvent);
|
||||
int indexToRemove = -1;
|
||||
for(int i = 0; i < dependencyList.size(); i++)
|
||||
for (int i = 0; i < dependencyList.size(); i++)
|
||||
{
|
||||
IBindable dependency = dependencyList.get(i);
|
||||
if (dependency.getClass().equals(eventClassToRemove))
|
||||
@@ -120,7 +120,7 @@ public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements
|
||||
{
|
||||
// if this is a one time event, record that it was called
|
||||
if (IDhApiOneTimeEvent.class.isAssignableFrom(abstractEventClass) &&
|
||||
!this.firedOneTimeEventParamsByEventInterface.containsKey(abstractEventClass))
|
||||
!this.firedOneTimeEventParamsByEventInterface.containsKey(abstractEventClass))
|
||||
{
|
||||
this.firedOneTimeEventParamsByEventInterface.put(abstractEventClass, eventInput);
|
||||
}
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
||||
|
||||
// make sure the given dependency implements the necessary interfaces
|
||||
boolean implementsInterface = this.checkIfClassImplements(dependencyImplementation.getClass(), dependencyInterface) ||
|
||||
this.checkIfClassExtends(dependencyImplementation.getClass(), dependencyInterface);
|
||||
this.checkIfClassExtends(dependencyImplementation.getClass(), dependencyInterface);
|
||||
boolean implementsBindable = this.checkIfClassImplements(dependencyImplementation.getClass(), this.bindableInterface);
|
||||
|
||||
// display any errors
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import java.util.HashMap;
|
||||
public class OverrideInjector implements IOverrideInjector<IDhApiOverrideable>
|
||||
{
|
||||
public static final OverrideInjector INSTANCE = new OverrideInjector();
|
||||
|
||||
|
||||
private final HashMap<Class<? extends IDhApiOverrideable>, OverridePriorityListContainer> overrideContainerByInterface = new HashMap<>();
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class OverrideInjector implements IOverrideInjector<IDhApiOverrideable>
|
||||
|
||||
|
||||
@Override
|
||||
public void bind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) throws IllegalStateException, IllegalArgumentException
|
||||
public void bind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) throws IllegalStateException, IllegalArgumentException
|
||||
{
|
||||
// make sure a override container exists
|
||||
OverridePriorityListContainer overrideContainer = this.overrideContainerByInterface.get(dependencyInterface);
|
||||
|
||||
+5
-3
@@ -7,8 +7,8 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Contains a list of overrides and their priorities.
|
||||
*
|
||||
* @author James Seibel
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-9-5
|
||||
*/
|
||||
public class OverridePriorityListContainer implements IBindable
|
||||
@@ -98,7 +98,7 @@ public class OverridePriorityListContainer implements IBindable
|
||||
// utils //
|
||||
|
||||
/** sort the list so the highest priority item is first in the list */
|
||||
private void sortList() { this.overridePairList.sort((x,y) -> Integer.compare(y.priority, x.priority)); }
|
||||
private void sortList() { this.overridePairList.sort((x, y) -> Integer.compare(y.priority, x.priority)); }
|
||||
|
||||
|
||||
|
||||
@@ -112,5 +112,7 @@ public class OverridePriorityListContainer implements IBindable
|
||||
this.override = newOverride;
|
||||
this.priority = newPriority;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -29,6 +29,7 @@ import java.util.HashMap;
|
||||
/**
|
||||
* This class takes care of dependency injection for world generators. <Br>
|
||||
* This is done so other mods can override our world generator(s) to improve or replace them.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-12-10
|
||||
*/
|
||||
@@ -65,10 +66,9 @@ public class WorldGeneratorInjector
|
||||
/**
|
||||
* Binds a world generator to the given level. <Br>
|
||||
* See {@link DependencyInjector#bind(Class, IBindable) bind(Class, IBindable)} for full documentation.
|
||||
*
|
||||
*
|
||||
* @throws NullPointerException if any parameter is null
|
||||
* @throws IllegalArgumentException if a non-Distant Horizons world generator with the priority CORE is passed in
|
||||
*
|
||||
* @see DependencyInjector#bind(Class, IBindable)
|
||||
*/
|
||||
public void bind(IDhApiLevelWrapper levelForWorldGenerator, IDhApiWorldGenerator worldGeneratorImplementation) throws NullPointerException, IllegalArgumentException
|
||||
@@ -98,8 +98,9 @@ public class WorldGeneratorInjector
|
||||
/**
|
||||
* Returns the bound world generator with the highest priority. <br>
|
||||
* Returns null if no world generators have been bound for this specific level. <br><br>
|
||||
*
|
||||
*
|
||||
* See {@link OverrideInjector#get(Class) get(Class)} for full documentation.
|
||||
*
|
||||
* @see OverrideInjector#get(Class)
|
||||
*/
|
||||
public IDhApiWorldGenerator get(IDhApiLevelWrapper levelForWorldGenerator) throws ClassCastException
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package com.seibel.distanthorizons.coreapi;
|
||||
|
||||
/**
|
||||
* This file is similar to mcmod.info
|
||||
/**
|
||||
* This file is similar to mcmod.info
|
||||
* and contains most meta-information related to Distant Horizons.
|
||||
*/
|
||||
public final class ModInfo
|
||||
@@ -37,7 +37,7 @@ public final class ModInfo
|
||||
public static final String VERSION = "2.0.0-a-dev";
|
||||
/** Returns true if the current build is an unstable developer build, false otherwise. */
|
||||
public static boolean IS_DEV_BUILD = VERSION.toLowerCase().contains("dev");
|
||||
|
||||
|
||||
/** This version should only be updated when breaking changes are introduced to the DH API */
|
||||
public static final int API_MAJOR_VERSION = 1;
|
||||
/** This version should be updated whenever new methods are added to the DH API */
|
||||
@@ -45,7 +45,7 @@ public final class ModInfo
|
||||
/** This version should be updated whenever non-breaking fixes are added to the DH API */
|
||||
public static final int API_PATH_VERSION = 0;
|
||||
|
||||
public static final String NETWORKING_RESOURCE_NAMESPACE = "distant_horizons";
|
||||
public static final String NETWORKING_RESOURCE_NAMESPACE = "distant_horizons";
|
||||
public static final String MULTIVERSE_PLUGIN_NAMESPACE = "world_control";
|
||||
|
||||
|
||||
|
||||
+35
-35
@@ -10,50 +10,50 @@ package com.seibel.distanthorizons.coreapi.interfaces.config;
|
||||
public interface IConfigEntry<T>
|
||||
{
|
||||
|
||||
/** Gets the default value of the option */
|
||||
T getDefaultValue();
|
||||
/** Gets the default value of the option */
|
||||
T getDefaultValue();
|
||||
|
||||
void setApiValue(T newApiValue);
|
||||
T getApiValue();
|
||||
void setApiValue(T newApiValue);
|
||||
T getApiValue();
|
||||
|
||||
/** Returns true if this config can be set via the API. */
|
||||
boolean getAllowApiOverride();
|
||||
|
||||
void set(T newValue);
|
||||
T get();
|
||||
T getTrueValue();
|
||||
void set(T newValue);
|
||||
T get();
|
||||
T getTrueValue();
|
||||
|
||||
/** Sets the value without saving */
|
||||
void setWithoutSaving(T newValue);
|
||||
/** Sets the value without saving */
|
||||
void setWithoutSaving(T newValue);
|
||||
|
||||
/** Gets the min value */
|
||||
T getMin();
|
||||
/** Sets the min value */
|
||||
void setMin(T newMin);
|
||||
/** Gets the max value */
|
||||
T getMax();
|
||||
/** Sets the max value */
|
||||
void setMax(T newMax);
|
||||
/** Sets the min and max in 1 setter */
|
||||
void setMinMax(T newMin, T newMax);
|
||||
/** Gets the min value */
|
||||
T getMin();
|
||||
/** Sets the min value */
|
||||
void setMin(T newMin);
|
||||
/** Gets the max value */
|
||||
T getMax();
|
||||
/** Sets the max value */
|
||||
void setMax(T newMax);
|
||||
/** Sets the min and max in 1 setter */
|
||||
void setMinMax(T newMin, T newMax);
|
||||
|
||||
/** Gets the comment */
|
||||
String getComment();
|
||||
/** Sets the comment */
|
||||
void setComment(String newComment);
|
||||
/** Gets the comment */
|
||||
String getComment();
|
||||
/** Sets the comment */
|
||||
void setComment(String newComment);
|
||||
|
||||
/**
|
||||
* Checks if the option is valid
|
||||
*
|
||||
* 0 == valid
|
||||
* 1 == number too high
|
||||
* -1 == number too low
|
||||
*/
|
||||
byte isValid();
|
||||
/** Checks if a value is valid */
|
||||
byte isValid(T value);
|
||||
/**
|
||||
* Checks if the option is valid
|
||||
*
|
||||
* 0 == valid
|
||||
* 1 == number too high
|
||||
* -1 == number too low
|
||||
*/
|
||||
byte isValid();
|
||||
/** Checks if a value is valid */
|
||||
byte isValid(T value);
|
||||
|
||||
/** Is the value of this equal to another */
|
||||
boolean equals(IConfigEntry<?> obj);
|
||||
/** Is the value of this equal to another */
|
||||
boolean equals(IConfigEntry<?> obj);
|
||||
|
||||
}
|
||||
|
||||
+6
-6
@@ -16,12 +16,12 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection;
|
||||
|
||||
/**
|
||||
* Necessary for all singletons that can be dependency injected.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-7-16
|
||||
*/
|
||||
@@ -29,12 +29,12 @@ public interface IBindable
|
||||
{
|
||||
/**
|
||||
* Finish initializing this object. <br> <br>
|
||||
*
|
||||
*
|
||||
* Generally this should just be used for getting other objects through
|
||||
* dependency injection and is specifically designed to allow
|
||||
* dependency injection and is specifically designed to allow
|
||||
* for circular references. <br><br>
|
||||
*
|
||||
* If no circular dependencies are required this method
|
||||
*
|
||||
* If no circular dependencies are required this method
|
||||
* doesn't have to be implemented.
|
||||
*/
|
||||
default void finishDelayedSetup() { }
|
||||
|
||||
+7
-8
@@ -30,19 +30,18 @@ public interface IDependencyInjector<BindableType extends IBindable>
|
||||
*
|
||||
* @see #get(Class, boolean)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
<T extends BindableType> T get(Class<T> interfaceClass) throws ClassCastException;
|
||||
@SuppressWarnings("unchecked") <T extends BindableType> T get(Class<T> interfaceClass) throws ClassCastException;
|
||||
|
||||
/**
|
||||
* Returns all dependencies of type T that have been bound. <br>
|
||||
* Returns an empty list if no dependencies have been bound.
|
||||
*
|
||||
* @param <T> class of the dependency
|
||||
* (inferred from the objectClass parameter)
|
||||
* (inferred from the objectClass parameter)
|
||||
* @param interfaceClass Interface of the dependency
|
||||
* @return the dependency of type T
|
||||
* @throws ClassCastException If the dependency isn't able to be cast to type T.
|
||||
* (this shouldn't normally happen, unless the bound object changed somehow)
|
||||
* (this shouldn't normally happen, unless the bound object changed somehow)
|
||||
*/
|
||||
<T extends BindableType> ArrayList<T> getAll(Class<T> interfaceClass) throws ClassCastException;
|
||||
|
||||
@@ -53,15 +52,14 @@ public interface IDependencyInjector<BindableType extends IBindable>
|
||||
* If the handler allows duplicate bindings, this will return the first bound dependency.
|
||||
*
|
||||
* @param <T> class of the dependency
|
||||
* (inferred from the interfaceClass parameter)
|
||||
* (inferred from the interfaceClass parameter)
|
||||
* @param interfaceClass Interface of the dependency
|
||||
* @param allowIncompleteDependencies If true this method will also return dependencies that haven't completed their delayed setup.
|
||||
* @return the dependency of type T
|
||||
* @throws ClassCastException If the dependency isn't able to be cast to type T.
|
||||
* (this shouldn't normally happen, unless the bound object changed somehow)
|
||||
* (this shouldn't normally happen, unless the bound object changed somehow)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
<T extends BindableType> T get(Class<T> interfaceClass, boolean allowIncompleteDependencies) throws ClassCastException;
|
||||
@SuppressWarnings("unchecked") <T extends BindableType> T get(Class<T> interfaceClass, boolean allowIncompleteDependencies) throws ClassCastException;
|
||||
|
||||
|
||||
|
||||
@@ -72,4 +70,5 @@ public interface IDependencyInjector<BindableType extends IBindable>
|
||||
|
||||
/** Runs delayed setup for any dependencies that require it. */
|
||||
void runDelayedSetup();
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public interface IOverrideInjector<BindableType extends IBindable>
|
||||
* @throws IllegalStateException if another override with the given priority already has been bound.
|
||||
* @see IDependencyInjector#bind(Class, IBindable)
|
||||
*/
|
||||
void bind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) throws IllegalStateException, IllegalArgumentException;
|
||||
void bind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) throws IllegalStateException, IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Returns the bound dependency with the highest priority. <br>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* <strong> Only For Internal Use </strong> <br> <!-- don't appear -->
|
||||
* Everything in here for DH internally use. <br><br>
|
||||
*
|
||||
*
|
||||
* You can use objects and methods from here if you want, (I'm a javaDoc, not the cops)
|
||||
* but using anything from this package is unsupported and may change at any time. <br><br>
|
||||
*
|
||||
*
|
||||
* When in doubt, if a method starts with "DhApi" it is safe to use, and we will
|
||||
* do our best to avoid breaking changes.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.coreapi;
|
||||
|
||||
@@ -3,20 +3,20 @@ package com.seibel.distanthorizons.coreapi.util;
|
||||
/**
|
||||
* A list of helper methods to make code easier to read. <br>
|
||||
* Specifically written because bit shifts short circuit James' brain.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-6
|
||||
*/
|
||||
public class BitShiftUtil
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Equivalent to: <br>
|
||||
* {@literal 1 << value0, } <br>
|
||||
* 2^value, <br>
|
||||
* Math.pow(2, value) <br><br>
|
||||
*
|
||||
*
|
||||
* Note: Math.pow() isn't identical for large values where bits would be lost in the shift, however for medium to small values they function the same. <br><br>
|
||||
*
|
||||
*
|
||||
* Can also be used to replace bit shifts in the format: <br>
|
||||
* {@literal multiplier << value; } <br>
|
||||
* multiplier * powerOfTwo(value);
|
||||
@@ -30,7 +30,7 @@ public class BitShiftUtil
|
||||
* Equivalent to: <br>
|
||||
* value >> 1, <br>
|
||||
* value / 2 <br><br>
|
||||
*
|
||||
*
|
||||
* Note: value / 2 isn't identical for negative values
|
||||
*/
|
||||
public static int half(int value) { return value >> 1; }
|
||||
@@ -42,7 +42,7 @@ public class BitShiftUtil
|
||||
* Equivalent to: <br>
|
||||
* value >> power, <br>
|
||||
* value / 2^power <br><br>
|
||||
*
|
||||
*
|
||||
* Note: value / 2^power isn't identical for negative values
|
||||
*/
|
||||
public static int divideByPowerOfTwo(int value, int power) { return value >> power; }
|
||||
@@ -55,7 +55,7 @@ public class BitShiftUtil
|
||||
* {@literal value << 1, } <br>
|
||||
* value^2, <br>
|
||||
* Math.pow(value, 2) <br><br>
|
||||
*
|
||||
*
|
||||
* Note: Math.pow() isn't identical for large values where bits would be lost in the shift, however for medium to small values they function the same.
|
||||
*/
|
||||
public static int square(int value) { return value << 1; }
|
||||
@@ -68,7 +68,7 @@ public class BitShiftUtil
|
||||
* {@literal value << power, } <br>
|
||||
* value^power, <br>
|
||||
* Math.pow(value, power) <br><br>
|
||||
*
|
||||
*
|
||||
* Note: Math.pow() isn't identical for large values where bits would be lost in the shift, however for medium to small values they function the same.
|
||||
*/
|
||||
public static int pow(int value, int power) { return value << power; }
|
||||
|
||||
@@ -49,7 +49,7 @@ public class MathUtil
|
||||
public static int log2(int numb)
|
||||
{
|
||||
// properties of logs allow us to use the base Log_e() method
|
||||
return (int)(Math.log(numb) / Math.log(2));
|
||||
return (int) (Math.log(numb) / Math.log(2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ public class StringUtil
|
||||
{
|
||||
int pos = str.indexOf(substr);
|
||||
while (--n > 0 && pos != -1)
|
||||
{
|
||||
pos = str.indexOf(substr, pos + 1);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -23,4 +23,5 @@ public class DefaultConverter<T> implements IConverter<T, T>
|
||||
{
|
||||
return coreObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import java.nio.FloatBuffer;
|
||||
/**
|
||||
* An (almost) exact copy of Minecraft's 1.16.5
|
||||
* implementation of a 4x4 float matrix.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 11-11-2021
|
||||
*/
|
||||
@@ -394,8 +394,8 @@ public class Mat4f
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO: what kind of translation is this?
|
||||
/**
|
||||
* TODO: what kind of translation is this?
|
||||
* and how is this different from "multiplyTranslationMatrix"?
|
||||
* Answer: This is faster and direct (but only if this is pure translation matrix without rotate)
|
||||
*/
|
||||
@@ -409,7 +409,7 @@ public class Mat4f
|
||||
/** originally "translate" from Minecraft's MatrixStack */
|
||||
public void multiplyTranslationMatrix(double x, double y, double z)
|
||||
{
|
||||
multiply(createTranslateMatrix((float)x, (float)y, (float)z));
|
||||
multiply(createTranslateMatrix((float) x, (float) y, (float) z));
|
||||
}
|
||||
|
||||
public Mat4f copy()
|
||||
@@ -450,30 +450,31 @@ public class Mat4f
|
||||
/** Returns the values of this matrix in row major order (AKA rows then columns) */
|
||||
public float[] getValuesAsArray()
|
||||
{
|
||||
return new float[] {
|
||||
this.m00,
|
||||
this.m01,
|
||||
this.m02,
|
||||
this.m03,
|
||||
|
||||
this.m10,
|
||||
this.m11,
|
||||
this.m12,
|
||||
this.m13,
|
||||
|
||||
this.m20,
|
||||
this.m21,
|
||||
this.m22,
|
||||
this.m23,
|
||||
|
||||
this.m30,
|
||||
this.m31,
|
||||
this.m32,
|
||||
this.m33,
|
||||
return new float[]{
|
||||
this.m00,
|
||||
this.m01,
|
||||
this.m02,
|
||||
this.m03,
|
||||
|
||||
this.m10,
|
||||
this.m11,
|
||||
this.m12,
|
||||
this.m13,
|
||||
|
||||
this.m20,
|
||||
this.m21,
|
||||
this.m22,
|
||||
this.m23,
|
||||
|
||||
this.m30,
|
||||
this.m31,
|
||||
this.m32,
|
||||
this.m33,
|
||||
};
|
||||
}
|
||||
|
||||
public Vec3f asNonNormalizedLookForwardVector() {
|
||||
|
||||
public Vec3f asNonNormalizedLookForwardVector()
|
||||
{
|
||||
return new Vec3f(this.m02, this.m12, this.m22);
|
||||
}
|
||||
|
||||
@@ -505,7 +506,7 @@ public class Mat4f
|
||||
{
|
||||
this(buffer.array());
|
||||
}
|
||||
|
||||
|
||||
public void set(Mat4f mat)
|
||||
{
|
||||
this.m00 = mat.m00;
|
||||
@@ -563,7 +564,7 @@ public class Mat4f
|
||||
this.m13 = y;
|
||||
this.m23 = z;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the values that store the clipping planes.
|
||||
* Formula for calculating matrix values is the same that OpenGL uses when making matrices.
|
||||
@@ -571,7 +572,7 @@ public class Mat4f
|
||||
* @param nearClip New near clipping plane value.
|
||||
* @param farClip New far clipping plane value.
|
||||
*/
|
||||
public void setClipPlanes(float nearClip,float farClip)
|
||||
public void setClipPlanes(float nearClip, float farClip)
|
||||
{
|
||||
//convert to matrix values, formula copied from a textbook / openGL specification.
|
||||
float matNearClip = -((farClip + nearClip) / (farClip - nearClip));
|
||||
|
||||
@@ -22,10 +22,10 @@ package com.seibel.distanthorizons.coreapi.util.math;
|
||||
import com.seibel.distanthorizons.coreapi.util.MathUtil;
|
||||
|
||||
/**
|
||||
* This is closer to MC's implementation of a
|
||||
* This is closer to MC's implementation of a
|
||||
* 3 element float vector than a 3 element double
|
||||
* vector. Hopefully that shouldn't cause any issues.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 11-18-2021
|
||||
*/
|
||||
@@ -254,4 +254,5 @@ public class Vec3d
|
||||
this.y = values[1];
|
||||
this.z = values[2];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
|
||||
/**
|
||||
* A (almost) exact copy of Minecraft's 1.16.5
|
||||
* implementation of a 3 element float vector.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 11-11-2021
|
||||
*/
|
||||
@@ -259,4 +259,5 @@ public class Vec3f
|
||||
this.y = values[1];
|
||||
this.z = values[2];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
|
||||
/**
|
||||
* A (almost) exact copy of Minecraft's 1.16.5
|
||||
* implementation of a 3 element integer vector.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-19
|
||||
*/
|
||||
@@ -134,8 +134,8 @@ public class Vec3i extends DhApiVec3i // extends the API object so it can be ret
|
||||
public Vec3i cross(Vec3i otherVec)
|
||||
{
|
||||
return new Vec3i(
|
||||
(this.y * otherVec.z) - (this.z * otherVec.y),
|
||||
(this.z * otherVec.x) - (this.x * otherVec.z),
|
||||
(this.y * otherVec.z) - (this.z * otherVec.y),
|
||||
(this.z * otherVec.x) - (this.x * otherVec.z),
|
||||
(this.x * otherVec.y) - (this.y * otherVec.x));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public abstract class AbstractDhApiCancelableOneTimeTestEvent implements IDhApiC
|
||||
//=========================//
|
||||
|
||||
@Override
|
||||
public final void fireEvent(DhApiCancelableEventParam<Boolean> input)
|
||||
public final void fireEvent(DhApiCancelableEventParam<Boolean> input)
|
||||
{
|
||||
this.onTestEvent(input);
|
||||
if (input.value)
|
||||
|
||||
@@ -133,7 +133,7 @@ public class EventInjectorTest
|
||||
oneTimeEventList = TEST_EVENT_HANDLER.getAll(AbstractDhApiCancelableOneTimeTestEvent.class);
|
||||
for (int i = 0; i < oneTimeEventList.size(); i++)
|
||||
{
|
||||
Assert.assertEquals("Event not fired for object ["+i+"].", true, oneTimeEventList.get(i).getTestValue());
|
||||
Assert.assertEquals("Event not fired for object [" + i + "].", true, oneTimeEventList.get(i).getTestValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* This is just a quick demo to confirm the testing system is set up correctly.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-9-5
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
|
||||
|
||||
/**
|
||||
* A singleton used to get variables from methods
|
||||
* where they are private or potentially absent.
|
||||
* where they are private or potentially absent.
|
||||
* Specifically the fog setting used by Optifine or the
|
||||
* presence/absence of other mods.
|
||||
* <p>
|
||||
@@ -32,7 +32,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
|
||||
* passing in interfaces), and it may be needed in the future if
|
||||
* we find that reflection handlers need to be different for
|
||||
* different MC versions.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-24
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ public interface IReflectionHandler extends IBindable
|
||||
{
|
||||
/** @return if Sodium (or a sodium like) mod is present. */
|
||||
boolean sodiumPresent();
|
||||
|
||||
|
||||
boolean optifinePresent();
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ import org.apache.logging.log4j.Logger;
|
||||
/** Handles first time Core setup. */
|
||||
public class Initializer
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger(ModInfo.NAME+"-"+Initializer.class.getSimpleName());
|
||||
private static final Logger LOGGER = LogManager.getLogger(ModInfo.NAME + "-" + Initializer.class.getSimpleName());
|
||||
|
||||
public static void init()
|
||||
public static void init()
|
||||
{
|
||||
// confirm that all referenced libraries are available to use
|
||||
try
|
||||
@@ -33,15 +33,15 @@ public class Initializer
|
||||
}
|
||||
catch (NoClassDefFoundError e)
|
||||
{
|
||||
LOGGER.fatal("Critical programmer error: One or more libraries aren't present. Error: ["+e.getMessage()+"].");
|
||||
LOGGER.fatal("Critical programmer error: One or more libraries aren't present. Error: [" + e.getMessage() + "].");
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CompleteFullDataSourceLoader unused2 = new CompleteFullDataSourceLoader(); // Auto register into the loader system
|
||||
HighDetailIncompleteFullDataSourceLoader unused3 = new HighDetailIncompleteFullDataSourceLoader(); // Auto register
|
||||
LowDetailIncompleteFullDataSourceLoader unused4 = new LowDetailIncompleteFullDataSourceLoader(); // Auto register
|
||||
CompleteFullDataSourceLoader unused2 = new CompleteFullDataSourceLoader(); // Auto register into the loader system
|
||||
HighDetailIncompleteFullDataSourceLoader unused3 = new HighDetailIncompleteFullDataSourceLoader(); // Auto register
|
||||
LowDetailIncompleteFullDataSourceLoader unused4 = new LowDetailIncompleteFullDataSourceLoader(); // Auto register
|
||||
|
||||
// link Core's config to the API
|
||||
DhApi.Delayed.configs = DhApiConfig.INSTANCE;
|
||||
@@ -49,5 +49,6 @@ public class Initializer
|
||||
DhApi.Delayed.worldProxy = DhApiWorldProxy.INSTANCE;
|
||||
DhApi.Delayed.renderProxy = DhApiRenderProxy.INSTANCE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOpt
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A singleton used to determine if a class is present or
|
||||
* access variables from methods where they are private
|
||||
* A singleton used to determine if a class is present or
|
||||
* access variables from methods where they are private
|
||||
* or potentially absent. <br><br>
|
||||
*
|
||||
*
|
||||
* For example: presence/absence of Optifine.
|
||||
*
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-11-24
|
||||
*/
|
||||
|
||||
Vendored
+4
-4
@@ -10,21 +10,21 @@ public class DhApiConfig implements IDhApiConfig
|
||||
{
|
||||
public static final DhApiConfig INSTANCE = new DhApiConfig();
|
||||
|
||||
private DhApiConfig() { }
|
||||
private DhApiConfig() { }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IDhApiGraphicsConfig graphics() { return DhApiGraphicsConfig.INSTANCE; }
|
||||
@Override
|
||||
@Override
|
||||
public IDhApiWorldGenerationConfig worldGenerator() { return DhApiWorldGenerationConfig.INSTANCE; }
|
||||
@Override
|
||||
public IDhApiMultiplayerConfig multiplayer() { return DhApiMultiplayerConfig.INSTANCE; }
|
||||
@Override
|
||||
public IDhApiMultiThreadingConfig multiThreading() { return DhApiMultiThreadingConfig.INSTANCE; }
|
||||
@Override
|
||||
@Override
|
||||
public IDhApiGpuBuffersConfig gpuBuffers() { return DhApiGpuBuffersConfig.INSTANCE; }
|
||||
@Override
|
||||
@Override
|
||||
public IDhApiDebuggingConfig debugging() { return DhApiDebuggingConfig.INSTANCE; }
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig
|
||||
//===========================//
|
||||
// advanced graphic settings //
|
||||
//===========================//
|
||||
|
||||
|
||||
// @Override
|
||||
// public IDhApiConfigValue<Boolean> getDisableDirectionalCulling()
|
||||
// { return new DhApiConfigValue<Boolean, Boolean>(AdvancedGraphics.disableDirectionalCulling); }
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGenerat
|
||||
*/
|
||||
public class DhApiWorldGenerationConfig implements IDhApiWorldGenerationConfig
|
||||
{
|
||||
public static DhApiWorldGenerationConfig INSTANCE = new DhApiWorldGenerationConfig();
|
||||
public static DhApiWorldGenerationConfig INSTANCE = new DhApiWorldGenerationConfig();
|
||||
|
||||
private DhApiWorldGenerationConfig() { }
|
||||
|
||||
|
||||
+21
-20
@@ -55,7 +55,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
|
||||
|
||||
|
||||
private DhApiTerrainDataRepo()
|
||||
private DhApiTerrainDataRepo()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -67,12 +67,12 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
//================//
|
||||
|
||||
@Override
|
||||
public DhApiResult<DhApiTerrainDataPoint> getSingleDataPointAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ)
|
||||
public DhApiResult<DhApiTerrainDataPoint> getSingleDataPointAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ)
|
||||
{
|
||||
return getTerrainDataAtBlockYPos(levelWrapper, new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPosX, blockPosZ), blockPosY);
|
||||
}
|
||||
@Override
|
||||
public DhApiResult<DhApiTerrainDataPoint[]> getColumnDataAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosZ)
|
||||
public DhApiResult<DhApiTerrainDataPoint[]> getColumnDataAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosZ)
|
||||
{
|
||||
return getTerrainDataColumnArray(levelWrapper, new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPosX, blockPosZ), null);
|
||||
}
|
||||
@@ -112,14 +112,14 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns all the block columns represented by the given {@link DhLodPos}. <br>
|
||||
* IE, A position with the detail level: <br>
|
||||
* 0 (block): will return a 1x1 matrix of data. (don't do this, we have a specific method for that.) <br>
|
||||
* 1 (2 blocks): will return a 2x2 matrix of data. <br>
|
||||
* 4 (chunk): will return a 16x16 matrix of data. <br> <br>
|
||||
*
|
||||
* will stop and return the in progress data if any errors are encountered.
|
||||
*
|
||||
* will stop and return the in progress data if any errors are encountered.
|
||||
*/
|
||||
private static DhApiResult<DhApiTerrainDataPoint[][][]> getTerrainDataOverAreaForPositionDetailLevel(IDhApiLevelWrapper levelWrapper, DhLodPos requestedAreaPos)
|
||||
{
|
||||
@@ -151,10 +151,10 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
return dataColumnsReturned != 0 ? DhApiResult.createSuccess("[" + dataColumnsReturned + "] columns returned.", returnArray) : DhApiResult.createSuccess("No data found.", returnArray);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* If nullableBlockYPos is null: returns every datapoint in the column defined by the DhLodPos. <br>
|
||||
* If nullableBlockYPos is NOT null: returns a single datapoint in the column defined by the DhLodPos which contains the block Y position. <br><br>
|
||||
*
|
||||
*
|
||||
* If the ApiResult is successful there will be an array of data. <br>
|
||||
* The returned array will be empty if no data could be retrieved.
|
||||
*/
|
||||
@@ -170,7 +170,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
{
|
||||
// custom level wrappers aren't supported,
|
||||
// the API user must get a level wrapper from our code somewhere
|
||||
return DhApiResult.createFail("Unsupported ["+IDhApiLevelWrapper.class.getSimpleName()+"] implementation, only the core class ["+ IDhLevel.class.getSimpleName()+"] is a valid parameter.");
|
||||
return DhApiResult.createFail("Unsupported [" + IDhApiLevelWrapper.class.getSimpleName() + "] implementation, only the core class [" + IDhLevel.class.getSimpleName() + "] is a valid parameter.");
|
||||
}
|
||||
ILevelWrapper coreLevelWrapper = (ILevelWrapper) levelWrapper;
|
||||
|
||||
@@ -256,7 +256,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
// shouldn't normally happen, but just in case
|
||||
LOGGER.error("Unexpected exception in getTerrainDataColumnArray. Error: ["+e.getMessage()+"]", e);
|
||||
LOGGER.error("Unexpected exception in getTerrainDataColumnArray. Error: [" + e.getMessage() + "]", e);
|
||||
return DhApiResult.createFail("Unexpected exception: [" + e.getMessage() + "].");
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
int height = FullDataPointUtil.getHeight(dataPoint);
|
||||
int topY = bottomY + height;
|
||||
|
||||
return new DhApiTerrainDataPoint(detailLevel,
|
||||
return new DhApiTerrainDataPoint(detailLevel,
|
||||
FullDataPointUtil.getLight(dataPoint), topY, bottomY,
|
||||
blockState, biomeWrapper);
|
||||
}
|
||||
@@ -282,7 +282,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
//====================//
|
||||
|
||||
@Override
|
||||
public DhApiResult<DhApiRaycastResult> raycast(IDhApiLevelWrapper levelWrapper,
|
||||
public DhApiResult<DhApiRaycastResult> raycast(
|
||||
IDhApiLevelWrapper levelWrapper,
|
||||
double rayOriginX, double rayOriginY, double rayOriginZ,
|
||||
float rayDirectionX, float rayDirectionY, float rayDirectionZ,
|
||||
int maxRayBlockLength)
|
||||
@@ -340,7 +341,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
{
|
||||
// does this LOD contain the given Y position?
|
||||
Vec3i dataPointPos = new Vec3i(columnPos.x, dataPoint.bottomYBlockPos, columnPos.z);
|
||||
if (exactPos.y >= dataPoint.bottomYBlockPos && exactPos.y <= dataPoint.topYBlockPos)
|
||||
if (exactPos.y >= dataPoint.bottomYBlockPos && exactPos.y <= dataPoint.topYBlockPos)
|
||||
{
|
||||
if (closetFoundDataPoint == null)
|
||||
{
|
||||
@@ -423,7 +424,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
{
|
||||
if (!(levelWrapper instanceof ILevelWrapper))
|
||||
{
|
||||
return DhApiResult.createFail("Level wrapper needs to be an instance of ["+IDhApiLevelWrapper.class.getSimpleName()+"].");
|
||||
return DhApiResult.createFail("Level wrapper needs to be an instance of [" + IDhApiLevelWrapper.class.getSimpleName() + "].");
|
||||
}
|
||||
AbstractDhWorld dhWorld = SharedApi.getAbstractDhWorld();
|
||||
if (dhWorld == null)
|
||||
@@ -452,8 +453,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
// debug methods //
|
||||
//===============//
|
||||
|
||||
/**
|
||||
* This method is here for debugging the repo and isn't intended for normal use.
|
||||
/**
|
||||
* This method is here for debugging the repo and isn't intended for normal use.
|
||||
* The method need to be async because pausing the main thread with a breakpoint and hot swapping will crash the program
|
||||
*/
|
||||
public static void asyncDebugMethod(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ)
|
||||
@@ -476,7 +477,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
if (rayCast.payload != null && !rayCast.payload.pos.equals(currentDebugVec3i))
|
||||
{
|
||||
currentDebugVec3i = rayCast.payload.pos;
|
||||
|
||||
|
||||
// get a string for the block
|
||||
String blockString = "[NULL BLOCK]"; // shouldn't normally happen unless there is an issue with getting the terrain at the given position
|
||||
if (rayCast.payload.dataPoint.blockStateWrapper != null)
|
||||
@@ -487,10 +488,10 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
}
|
||||
else
|
||||
{
|
||||
blockString = "[AIR]";
|
||||
blockString = "[AIR]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LOGGER.info("raycast: " + currentDebugVec3i + "\t block: " + blockString);
|
||||
}
|
||||
else if (rayCast.payload == null && currentDebugVec3i != null)
|
||||
@@ -504,7 +505,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Test method Error: ["+e.getMessage()+"]", e);
|
||||
LOGGER.error("Test method Error: [" + e.getMessage() + "]", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ClientApi
|
||||
// world events //
|
||||
//==============//
|
||||
|
||||
/**
|
||||
/**
|
||||
* May be fired slightly before or after the associated
|
||||
* {@link ClientApi#clientLevelLoadEvent(IClientLevelWrapper)} event
|
||||
* depending on how the host mod loader functions.
|
||||
@@ -123,7 +123,7 @@ public class ClientApi
|
||||
SharedApi.setDhWorld(new DhClientWorld());
|
||||
|
||||
|
||||
LOGGER.info("Loading ["+this.waitingClientLevels.size()+"] waiting client level wrappers.");
|
||||
LOGGER.info("Loading [" + this.waitingClientLevels.size() + "] waiting client level wrappers.");
|
||||
for (IClientLevelWrapper level : this.waitingClientLevels)
|
||||
{
|
||||
this.clientLevelLoadEvent(level);
|
||||
@@ -132,7 +132,7 @@ public class ClientApi
|
||||
this.waitingClientLevels.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onClientOnlyDisconnected()
|
||||
{
|
||||
if (MC.clientConnectedToDedicatedServer())
|
||||
@@ -141,7 +141,7 @@ public class ClientApi
|
||||
if (world != null)
|
||||
{
|
||||
LOGGER.info("Client on ClientOnly mode disconnecting.");
|
||||
|
||||
|
||||
world.close();
|
||||
SharedApi.setDhWorld(null);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class ClientApi
|
||||
|
||||
public void clientLevelUnloadEvent(IClientLevelWrapper level)
|
||||
{
|
||||
LOGGER.info("Unloading client level ["+level+"].");
|
||||
LOGGER.info("Unloading client level [" + level + "].");
|
||||
|
||||
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
|
||||
if (world != null)
|
||||
@@ -191,7 +191,7 @@ public class ClientApi
|
||||
}
|
||||
|
||||
|
||||
LOGGER.info("Loading "+(isServerCommunication ? "Multiverse" : "")+" client level [" + level + "].");
|
||||
LOGGER.info("Loading " + (isServerCommunication ? "Multiverse" : "") + " client level [" + level + "].");
|
||||
|
||||
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
|
||||
if (world != null)
|
||||
@@ -220,7 +220,7 @@ public class ClientApi
|
||||
keysToRemove.add(levelChunkPair);
|
||||
}
|
||||
}
|
||||
LOGGER.info("Loaded ["+keysToRemove.size()+"] waiting chunk wrappers.");
|
||||
LOGGER.info("Loaded [" + keysToRemove.size() + "] waiting chunk wrappers.");
|
||||
|
||||
for (Pair<IClientLevelWrapper, DhChunkPos> keyToRemove : keysToRemove)
|
||||
{
|
||||
@@ -263,8 +263,8 @@ public class ClientApi
|
||||
{
|
||||
for (int zOffset = -1; zOffset <= 1; zOffset++)
|
||||
{
|
||||
DhChunkPos neighbourPos = new DhChunkPos(chunk.getChunkPos().x+xOffset, chunk.getChunkPos().z+zOffset);
|
||||
IChunkWrapper neighbourChunk = dhLevel.getLevelWrapper().tryGetChunk(neighbourPos);
|
||||
DhChunkPos neighbourPos = new DhChunkPos(chunk.getChunkPos().x + xOffset, chunk.getChunkPos().z + zOffset);
|
||||
IChunkWrapper neighbourChunk = dhLevel.getLevelWrapper().tryGetChunk(neighbourPos);
|
||||
if (neighbourChunk != null)
|
||||
{
|
||||
dhLevel.updateChunkAsync(neighbourChunk);
|
||||
@@ -282,20 +282,20 @@ public class ClientApi
|
||||
public void rendererShutdownEvent()
|
||||
{
|
||||
LOGGER.info("Renderer shutting down.");
|
||||
|
||||
|
||||
IProfilerWrapper profiler = MC.getProfiler();
|
||||
profiler.push("DH-RendererShutdown");
|
||||
|
||||
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
public void rendererStartupEvent()
|
||||
{
|
||||
LOGGER.info("Renderer starting up.");
|
||||
|
||||
|
||||
IProfilerWrapper profiler = MC.getProfiler();
|
||||
profiler.push("DH-RendererStartup");
|
||||
|
||||
|
||||
// make sure the GLProxy is created before the LodBufferBuilder needs it
|
||||
GLProxy.getInstance();
|
||||
profiler.pop();
|
||||
@@ -305,7 +305,7 @@ public class ClientApi
|
||||
{
|
||||
IProfilerWrapper profiler = MC.getProfiler();
|
||||
profiler.push("DH-ClientTick");
|
||||
|
||||
|
||||
boolean doFlush = System.nanoTime() - this.lastFlushNanoTime >= SPAM_LOGGER_FLUSH_NS;
|
||||
if (doFlush)
|
||||
{
|
||||
@@ -314,7 +314,7 @@ public class ClientApi
|
||||
}
|
||||
ConfigBasedLogger.updateAll();
|
||||
ConfigBasedSpamLogger.updateAll(doFlush);
|
||||
|
||||
|
||||
IDhClientWorld clientWorld = SharedApi.getIDhClientWorld();
|
||||
if (clientWorld != null)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ public class ClientApi
|
||||
//============//
|
||||
// networking //
|
||||
//============//
|
||||
|
||||
|
||||
// /** @param byteBuf is Netty's {@link ByteBuffer} wrapper. */
|
||||
// public void serverMessageReceived(ByteBuf byteBuf)
|
||||
// {
|
||||
@@ -463,8 +463,8 @@ public class ClientApi
|
||||
MC.sendChatMessage("Here be dragons!");
|
||||
this.configOverrideReminderPrinted = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
IProfilerWrapper profiler = MC.getProfiler();
|
||||
profiler.pop(); // get out of "terrain"
|
||||
profiler.push("DH-RenderLevel");
|
||||
@@ -474,20 +474,20 @@ public class ClientApi
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//FIXME: Improve class hierarchy of DhWorld, IClientWorld, IServerWorld to fix all this hard casting
|
||||
// (also in RenderUtil)
|
||||
IDhClientWorld dhClientWorld = SharedApi.getIDhClientWorld();
|
||||
IDhClientLevel level = dhClientWorld.getOrLoadClientLevel(levelWrapper);
|
||||
|
||||
|
||||
if (prefLoggerEnabled)
|
||||
{
|
||||
level.dumpRamUsage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
@@ -495,9 +495,9 @@ public class ClientApi
|
||||
{
|
||||
DhApiRenderParam renderEventParam =
|
||||
new DhApiRenderParam(mcProjectionMatrix, mcModelViewMatrix,
|
||||
RenderUtil.createLodProjectionMatrix(mcProjectionMatrix, partialTicks),
|
||||
RenderUtil.createLodModelViewMatrix(mcModelViewMatrix), partialTicks);
|
||||
|
||||
RenderUtil.createLodProjectionMatrix(mcProjectionMatrix, partialTicks),
|
||||
RenderUtil.createLodModelViewMatrix(mcModelViewMatrix), partialTicks);
|
||||
|
||||
boolean renderingCanceled = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderEvent.class, new DhApiBeforeRenderEvent.EventParam(renderEventParam));
|
||||
if (!this.rendererDisabledBecauseOfExceptions && !renderingCanceled)
|
||||
{
|
||||
@@ -517,7 +517,7 @@ public class ClientApi
|
||||
{
|
||||
this.rendererDisabledBecauseOfExceptions = true;
|
||||
LOGGER.error("Renderer thrown an uncaught exception: ", e);
|
||||
|
||||
|
||||
MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons"
|
||||
+ " renderer has encountered an exception!");
|
||||
MC.sendChatMessage("\u00A74Renderer is now disabled to prevent further issues.");
|
||||
@@ -534,13 +534,13 @@ public class ClientApi
|
||||
profiler.push("terrain"); // go back into "terrain"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=================//
|
||||
// DEBUG USE //
|
||||
//=================//
|
||||
|
||||
|
||||
/** Trigger once on key press, with CLIENT PLAYER. */
|
||||
public void keyPressedEvent(int glfwKey)
|
||||
{
|
||||
@@ -549,8 +549,8 @@ public class ClientApi
|
||||
// keybindings are disabled
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (glfwKey == GLFW.GLFW_KEY_F8)
|
||||
{
|
||||
Config.Client.Advanced.Debugging.debugRendering.set(EDebugRendering.next(Config.Client.Advanced.Debugging.debugRendering.get()));
|
||||
@@ -567,6 +567,6 @@ public class ClientApi
|
||||
MC.sendChatMessage("P: Debug Pref Logger is " + (prefLoggerEnabled ? "enabled" : "disabled"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -79,23 +79,23 @@ public class ServerApi
|
||||
catch (Exception e)
|
||||
{
|
||||
// try catch is necessary to prevent crashing the internal server when an exception is thrown
|
||||
LOGGER.error("ServerTickEvent error: "+e.getMessage(), e);
|
||||
LOGGER.error("ServerTickEvent error: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
public void serverLevelTickEvent(IServerLevelWrapper level)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
||||
public void serverLoadEvent(boolean isDedicatedEnvironment)
|
||||
{
|
||||
LOGGER.debug("Server World loading with (dedicated?:"+isDedicatedEnvironment+")");
|
||||
LOGGER.debug("Server World loading with (dedicated?:" + isDedicatedEnvironment + ")");
|
||||
SharedApi.setDhWorld(isDedicatedEnvironment ? new DhServerWorld() : new DhClientServerWorld());
|
||||
}
|
||||
|
||||
public void serverUnloadEvent()
|
||||
{
|
||||
LOGGER.debug("Server World "+SharedApi.getAbstractDhWorld()+" unloading");
|
||||
LOGGER.debug("Server World " + SharedApi.getAbstractDhWorld() + " unloading");
|
||||
|
||||
SharedApi.getAbstractDhWorld().close();
|
||||
SharedApi.setDhWorld(null);
|
||||
@@ -103,7 +103,7 @@ public class ServerApi
|
||||
|
||||
public void serverLevelLoadEvent(IServerLevelWrapper level)
|
||||
{
|
||||
LOGGER.debug("Server Level "+level+" loading");
|
||||
LOGGER.debug("Server Level " + level + " loading");
|
||||
|
||||
AbstractDhWorld serverWorld = SharedApi.getAbstractDhWorld();
|
||||
if (serverWorld != null)
|
||||
@@ -114,7 +114,7 @@ public class ServerApi
|
||||
}
|
||||
public void serverLevelUnloadEvent(IServerLevelWrapper level)
|
||||
{
|
||||
LOGGER.debug("Server Level "+level+" unloading");
|
||||
LOGGER.debug("Server Level " + level + " unloading");
|
||||
|
||||
AbstractDhWorld serverWorld = SharedApi.getAbstractDhWorld();
|
||||
if (serverWorld != null)
|
||||
@@ -123,11 +123,11 @@ public class ServerApi
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelUnloadEvent.class, new DhApiLevelUnloadEvent.EventParam(level));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Deprecated // TODO not implemented, remove
|
||||
public void serverSaveEvent()
|
||||
{
|
||||
LOGGER.debug("Server world "+SharedApi.getAbstractDhWorld()+" saving");
|
||||
LOGGER.debug("Server world " + SharedApi.getAbstractDhWorld() + " saving");
|
||||
|
||||
AbstractDhWorld serverWorld = SharedApi.getAbstractDhWorld();
|
||||
if (serverWorld != null)
|
||||
@@ -135,7 +135,7 @@ public class ServerApi
|
||||
serverWorld.saveAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void serverChunkLoadEvent(IChunkWrapper chunk, ILevelWrapper level)
|
||||
{
|
||||
// the world should always be non-null, this != null is just in case the world was removed accidentally
|
||||
|
||||
@@ -11,21 +11,21 @@ import com.seibel.distanthorizons.core.world.*;
|
||||
/** Contains code and variables used by both {@link ClientApi} and {@link ServerApi} */
|
||||
public class SharedApi
|
||||
{
|
||||
private static AbstractDhWorld currentWorld;
|
||||
|
||||
private static AbstractDhWorld currentWorld;
|
||||
|
||||
|
||||
|
||||
public static void init() { Initializer.init(); }
|
||||
|
||||
public static void init() { Initializer.init(); }
|
||||
|
||||
|
||||
|
||||
public static EWorldEnvironment getEnvironment() { return (currentWorld == null) ? null : currentWorld.environment; }
|
||||
|
||||
|
||||
public static void setDhWorld(AbstractDhWorld newWorld)
|
||||
public static void setDhWorld(AbstractDhWorld newWorld)
|
||||
{
|
||||
currentWorld = newWorld;
|
||||
currentWorld = newWorld;
|
||||
|
||||
// starting and stopping the DataRenderTransformer is necessary to prevent attempting to
|
||||
// access the MC level at inappropriate times, which can cause exceptions
|
||||
|
||||
@@ -5,31 +5,31 @@ import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
// TODO: Make this intergrate with the config system
|
||||
public class AppliedConfigState<T>
|
||||
{
|
||||
final ConfigEntry<T> entry;
|
||||
T activeValue;
|
||||
final ConfigEntry<T> entry;
|
||||
T activeValue;
|
||||
|
||||
|
||||
|
||||
public AppliedConfigState(ConfigEntry<T> entryToWatch)
|
||||
public AppliedConfigState(ConfigEntry<T> entryToWatch)
|
||||
{
|
||||
this.entry = entryToWatch;
|
||||
this.activeValue = entryToWatch.get();
|
||||
}
|
||||
this.entry = entryToWatch;
|
||||
this.activeValue = entryToWatch.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Returns true if the value was changed */
|
||||
public boolean pollNewValue()
|
||||
public boolean pollNewValue()
|
||||
{
|
||||
T newValue = this.entry.get();
|
||||
if (newValue.equals(this.activeValue))
|
||||
T newValue = this.entry.get();
|
||||
if (newValue.equals(this.activeValue))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.activeValue = newValue;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public T get() { return this.activeValue; }
|
||||
public T get() { return this.activeValue; }
|
||||
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ import java.util.*;
|
||||
|
||||
/**
|
||||
* This handles any configuration the user has access to. <br><br>
|
||||
*
|
||||
*
|
||||
* Note: <br>
|
||||
* Only add simpler listeners here (IE listeners that only depend on 1 config entry).
|
||||
* For listeners that depend on 2 or more config entries, add them before the config menu is opened.
|
||||
* Otherwise, you will have issues where only some of the config entries will exist when your listener is created.
|
||||
*
|
||||
*
|
||||
* @author coolGi
|
||||
* @version 2023-7-16
|
||||
*/
|
||||
@@ -57,11 +57,11 @@ public class Config
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
public static ConfigCategory client = new ConfigCategory.Builder().set(Client.class).build();
|
||||
public static ConfigCategory client = new ConfigCategory.Builder().set(Client.class).build();
|
||||
|
||||
|
||||
public static class Client
|
||||
{
|
||||
public static class Client
|
||||
{
|
||||
public static ConfigEntry<Boolean> quickEnableRendering = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment(""
|
||||
@@ -105,7 +105,7 @@ public class Config
|
||||
public static ConfigEntry<Boolean> optionsButton = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment("" +
|
||||
"Should Distant Horizon's config button appear in the options screen next to fov slider?")
|
||||
"Should Distant Horizon's config button appear in the options screen next to fov slider?")
|
||||
.build();
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public class Config
|
||||
+ "\n"
|
||||
+ "True: a red flower will tint the grass below it red. \n"
|
||||
+ "False: skipped blocks will not change color of surface below them. "
|
||||
+"")
|
||||
+ "")
|
||||
.setPerformance(EConfigEntryPerformance.NONE)
|
||||
.addListener(RenderCacheConfigEventHandler.INSTANCE)
|
||||
.build();
|
||||
@@ -310,7 +310,7 @@ public class Config
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Double> farFogMin = new ConfigEntry.Builder<Double>()
|
||||
.setMinDefaultMax(-5.0,0.0, FOG_RANGE_MAX)
|
||||
.setMinDefaultMax(-5.0, 0.0, FOG_RANGE_MAX)
|
||||
.comment(""
|
||||
+ "What is the minimum fog thickness? \n"
|
||||
+ "\n"
|
||||
@@ -338,7 +338,7 @@ public class Config
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Double> farFogDensity = new ConfigEntry.Builder<Double>()
|
||||
.setMinDefaultMax(0.01,2.5, 50.0)
|
||||
.setMinDefaultMax(0.01, 2.5, 50.0)
|
||||
.comment(""
|
||||
+ "Used in conjunction with the Fog Falloff.")
|
||||
.build();
|
||||
@@ -367,7 +367,7 @@ public class Config
|
||||
+ EHeightFogMixMode.INVERSE_MULTIPLY_ADDITION + ": farFog + 1 - (1-heightFog) * (1-farFog) \n"
|
||||
+ EHeightFogMixMode.AVERAGE + ": farFog*0.5 + heightFog*0.5 \n"
|
||||
+ "\n"
|
||||
+ "Note: height fog settings are ignored if '"+EHeightFogMixMode.BASIC+"' or '"+EHeightFogMixMode.IGNORE_HEIGHT+"' are selected.")
|
||||
+ "Note: height fog settings are ignored if '" + EHeightFogMixMode.BASIC + "' or '" + EHeightFogMixMode.IGNORE_HEIGHT + "' are selected.")
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<EHeightFogMode> heightFogMode = new ConfigEntry.Builder<EHeightFogMode>()
|
||||
@@ -440,7 +440,9 @@ public class Config
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class NoiseTextureSettings
|
||||
@@ -449,7 +451,7 @@ public class Config
|
||||
.set(true)
|
||||
.comment(""
|
||||
+ "Should a noise texture be applied to LODs? \n"
|
||||
+"\n"
|
||||
+ "\n"
|
||||
+ "This is done to simulate textures and make the LODs appear more detailed. \n"
|
||||
+ "")
|
||||
.build();
|
||||
@@ -472,6 +474,7 @@ public class Config
|
||||
+ "Defines how far should the noise texture render before it fades away. (in blocks) \n"
|
||||
+ "Set to 0 to disable noise from fading away")
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public static class AdvancedGraphics
|
||||
@@ -512,7 +515,7 @@ public class Config
|
||||
+ "reducing overdraw. \n"
|
||||
+ "\n"
|
||||
+ "Only functional on Fabric.\n"
|
||||
+ "Works best with an overdraw prevention setting of "+EOverdrawPrevention.MEDIUM+" or higher \n"
|
||||
+ "Works best with an overdraw prevention setting of " + EOverdrawPrevention.MEDIUM + " or higher \n"
|
||||
+ " and cave culling is disabled. \n"
|
||||
+ "")
|
||||
.setPerformance(EConfigEntryPerformance.NONE)
|
||||
@@ -553,13 +556,13 @@ public class Config
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Integer> caveCullingHeight = new ConfigEntry.Builder<Integer>()
|
||||
.setMinDefaultMax(-4096,40,4096)
|
||||
.comment(""
|
||||
.setMinDefaultMax(-4096, 40, 4096)
|
||||
.comment(""
|
||||
+ "At what Y value should cave culling start?")
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Integer> earthCurveRatio = new ConfigEntry.Builder<Integer>()
|
||||
.setMinDefaultMax(0,0,5000)
|
||||
.setMinDefaultMax(0, 0, 5000)
|
||||
.comment(""
|
||||
+ "This is the earth size ratio when applying the curvature shader effect. \n"
|
||||
+ "Note: Enabling this feature may cause rendering bugs. \n"
|
||||
@@ -643,14 +646,14 @@ public class Config
|
||||
+ "WARNING: This may cause world generator bugs or instability when paired with certain world generator mods. \n"
|
||||
+ "- Fast \n"
|
||||
+ "")
|
||||
/*
|
||||
// FULL isn't currently implemented
|
||||
+ "\n"
|
||||
+ EDhApiDistantGeneratorMode.FULL + " \n"
|
||||
+ "Ask the local server to generate/load each chunk. \n"
|
||||
+ "This is the most compatible, but will cause server/simulation lag. \n"
|
||||
+ "- Slow (15-50 ms, with spikes up to 200 ms) \n"
|
||||
*/
|
||||
/*
|
||||
// FULL isn't currently implemented
|
||||
+ "\n"
|
||||
+ EDhApiDistantGeneratorMode.FULL + " \n"
|
||||
+ "Ask the local server to generate/load each chunk. \n"
|
||||
+ "This is the most compatible, but will cause server/simulation lag. \n"
|
||||
+ "- Slow (15-50 ms, with spikes up to 200 ms) \n"
|
||||
*/
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<ELightGenerationMode> worldGenLightingEngine = new ConfigEntry.Builder<ELightGenerationMode>()
|
||||
@@ -667,7 +670,7 @@ public class Config
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Integer> worldGenerationTimeoutLengthInSeconds = new ConfigEntry.Builder<Integer>()
|
||||
.setMinDefaultMax(5, 60, 60*10/*10 minutes*/)
|
||||
.setMinDefaultMax(5, 60, 60 * 10/*10 minutes*/ )
|
||||
.comment(""
|
||||
+ "How long should a world generator thread run for before timing out? \n"
|
||||
+ "Note: If you are experiencing timeout errors it is better to lower your CPU usage first \n"
|
||||
@@ -695,7 +698,7 @@ public class Config
|
||||
+ " fake chunks. \n"
|
||||
+ "\n"
|
||||
+ EGenerationPriority.BALANCED + " \n"
|
||||
+ "A mix between "+ EGenerationPriority.NEAR_FIRST+"and"+ EGenerationPriority.FAR_FIRST+". \n"
|
||||
+ "A mix between " + EGenerationPriority.NEAR_FIRST + "and" + EGenerationPriority.FAR_FIRST + ". \n"
|
||||
+ "First prioritise completing nearby highest detail chunks, \n"
|
||||
+ " then focus on filling in the low detail areas away from the player. \n"
|
||||
+ "\n"
|
||||
@@ -933,6 +936,7 @@ public class Config
|
||||
+ "How frequently should vertex buffers (geometry) be rebuilt and sent to the GPU? \n"
|
||||
+ "Higher settings may cause stuttering, but will prevent holes in the world")
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public static class AutoUpdater
|
||||
@@ -945,10 +949,11 @@ public class Config
|
||||
|
||||
public static ConfigEntry<Boolean> enableSilentUpdates = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.comment(""
|
||||
.comment(""
|
||||
+ "Should Distant Horizons silently, automatically download and install new versions? "
|
||||
+ "")
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public static class Logging
|
||||
@@ -1017,6 +1022,7 @@ public class Config
|
||||
+ "If enabled, the mod will log information about network operations. \n"
|
||||
+ "This can be useful for debugging.")
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public static class Debugging
|
||||
@@ -1068,7 +1074,7 @@ public class Config
|
||||
+ " This setting is only for fun and debugging. \n"
|
||||
+ " Mod compatibility is not guaranteed.")
|
||||
.build();
|
||||
|
||||
|
||||
public static ConfigEntry<Boolean> debugWireframeRendering = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.comment(""
|
||||
@@ -1078,21 +1084,21 @@ public class Config
|
||||
+ " Additionally, only stuff that's loaded after you enable this \n"
|
||||
+ " will render their debug wireframes.")
|
||||
.build();
|
||||
|
||||
|
||||
public static ConfigEntry<Boolean> enableWhiteWorld = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.comment(""
|
||||
+ "Stops vertex colors from being passed. \n"
|
||||
+ "Useful for debugging shaders")
|
||||
.build();
|
||||
|
||||
|
||||
// Note: This will reset on game restart, and should have a warning on the tooltip
|
||||
public static ConfigEntry<Boolean> allowUnsafeValues = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_GUI)
|
||||
.addListener(UnsafeValuesConfigListener.INSTANCE)
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
// can be set to public inorder to show in the config file and UI
|
||||
public static ConfigCategory exampleConfigScreen = new ConfigCategory.Builder()
|
||||
@@ -1130,7 +1136,7 @@ public class Config
|
||||
public static ConfigEntry<Long> longTest = new ConfigEntry.Builder<Long>()
|
||||
.set(42069L)
|
||||
.build();
|
||||
|
||||
|
||||
public static ConfigEntry<Float> floatTest = new ConfigEntry.Builder<Float>()
|
||||
.set(0.42069f)
|
||||
.build();
|
||||
@@ -1142,15 +1148,15 @@ public class Config
|
||||
public static ConfigEntry<List<String>> listTest = new ConfigEntry.Builder<List<String>>()
|
||||
.set(new ArrayList<String>(Arrays.asList("option 1", "option 2", "option 3")))
|
||||
.build();
|
||||
|
||||
|
||||
public static ConfigEntry<Map<String, String>> mapTest = new ConfigEntry.Builder<Map<String, String>>()
|
||||
.set(new HashMap<String, String>())
|
||||
.build();
|
||||
|
||||
|
||||
public static ConfigUIButton uiButtonTest = new ConfigUIButton(() -> {
|
||||
System.setProperty("java.awt.headless", "false"); // Required to make it work
|
||||
JOptionPane.showMessageDialog(null, "Button pressed!", "UITester dialog", JOptionPane.INFORMATION_MESSAGE);
|
||||
});
|
||||
JOptionPane.showMessageDialog(null, "Button pressed!", "UITester dialog", JOptionPane.INFORMATION_MESSAGE);
|
||||
});
|
||||
|
||||
public static ConfigCategory categoryTest = new ConfigCategory.Builder().set(CategoryTest.class).build();
|
||||
|
||||
@@ -1163,7 +1169,9 @@ public class Config
|
||||
{
|
||||
// The name of this can be anything as it will be overwritten by the name of the linked object
|
||||
public static ConfigLinkedEntry linkableTest = new ConfigLinkedEntry(ExampleConfigScreen.linkableTest);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1184,7 +1192,7 @@ public class Config
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1193,10 +1201,10 @@ public class Config
|
||||
/**
|
||||
* Runs any config setup that needs all (or most) config entries be initialized (not null),
|
||||
* but doesn't necessarily require they have the right values yet. <br><br>
|
||||
*
|
||||
*
|
||||
* Specially:
|
||||
* Updates any config values that are UI only
|
||||
* and adds any listeners that depend on multiple config values.
|
||||
* Updates any config values that are UI only
|
||||
* and adds any listeners that depend on multiple config values.
|
||||
*/
|
||||
public static void completeDelayedSetup()
|
||||
{
|
||||
@@ -1208,11 +1216,11 @@ public class Config
|
||||
{
|
||||
ThreadPresetConfigEventHandler.INSTANCE.setUiOnlyConfigValues();
|
||||
RenderQualityPresetConfigEventHandler.INSTANCE.setUiOnlyConfigValues();
|
||||
QuickRenderToggleConfigEventHandler.INSTANCE.setUiOnlyConfigValues();
|
||||
QuickRenderToggleConfigEventHandler.INSTANCE.setUiOnlyConfigValues();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Unexpected exception when setting up complicated config listeners. Error: ["+e.getMessage()+"].", e);
|
||||
LOGGER.error("Unexpected exception when setting up complicated config listeners. Error: [" + e.getMessage() + "].", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,181 +20,205 @@ import java.util.*;
|
||||
* @author Ran
|
||||
*/
|
||||
// Init the config after singletons have been blinded
|
||||
public class ConfigBase
|
||||
public class ConfigBase
|
||||
{
|
||||
/** Our own config instance, don't modify */
|
||||
public static ConfigBase INSTANCE;
|
||||
public ConfigFileHandling configFileINSTANCE;
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(ConfigBase.class.getSimpleName());
|
||||
public final String modID;
|
||||
public final String modName;
|
||||
public final int configVersion;
|
||||
/** Our own config instance, don't modify */
|
||||
public static ConfigBase INSTANCE;
|
||||
public ConfigFileHandling configFileINSTANCE;
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(ConfigBase.class.getSimpleName());
|
||||
public final String modID;
|
||||
public final String modName;
|
||||
public final int configVersion;
|
||||
|
||||
/**
|
||||
* What the config works with
|
||||
*
|
||||
* Enum
|
||||
* Boolean
|
||||
* Byte
|
||||
* Integer
|
||||
* Double
|
||||
* Short
|
||||
* Long
|
||||
* Float
|
||||
* String
|
||||
*
|
||||
* // Below, "T" should be a value from above
|
||||
* List<T>
|
||||
* ArrayList<T>
|
||||
* Map<String, T>
|
||||
* HashMap<String, T>
|
||||
*/
|
||||
public static final List<Class<?>> acceptableInputs = new ArrayList<Class<?>>()
|
||||
{{
|
||||
add(Boolean.class);
|
||||
add(Byte.class);
|
||||
add(Integer.class);
|
||||
add(Double.class);
|
||||
add(Short.class);
|
||||
add(Long.class);
|
||||
add(Float.class);
|
||||
add(String.class);
|
||||
|
||||
// TODO[CONFIG]: Check the type of these is valid
|
||||
add(List.class);
|
||||
add(ArrayList.class);
|
||||
add(Map.class);
|
||||
add(HashMap.class);
|
||||
}};
|
||||
|
||||
/** Disables the minimum and maximum of any variable */
|
||||
public boolean disableMinMax = false; // Very fun to use, but should always be disabled by default
|
||||
public final List<AbstractConfigType<?, ?>> entries = new ArrayList<>();
|
||||
|
||||
|
||||
public ConfigBase(String modID, String modName, Class<?> config, int configVersion)
|
||||
{
|
||||
LOGGER.info("Initialising config for " + modName);
|
||||
this.modID = modID;
|
||||
this.modName = modName;
|
||||
this.configVersion = configVersion;
|
||||
|
||||
initNestedClass(config, ""); // Init root category
|
||||
|
||||
// File handling (load from file)
|
||||
this.configFileINSTANCE = new ConfigFileHandling(this);
|
||||
this.configFileINSTANCE.loadFromFile();
|
||||
LOGGER.info("Config for " + modName + " initialised");
|
||||
}
|
||||
|
||||
private void initNestedClass(Class<?> config, String category)
|
||||
{
|
||||
// Put all the entries in entries
|
||||
|
||||
for (Field field : config.getFields())
|
||||
{
|
||||
if (AbstractConfigType.class.isAssignableFrom(field.getType()))
|
||||
{
|
||||
try
|
||||
{
|
||||
entries.add((AbstractConfigType<?, ?>) field.get(field.getType()));
|
||||
}
|
||||
catch (IllegalAccessException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
AbstractConfigType<?, ?> entry = entries.get(entries.size() - 1);
|
||||
entry.category = category;
|
||||
entry.name = field.getName();
|
||||
entry.configBase = this;
|
||||
|
||||
if (ConfigEntry.class.isAssignableFrom(field.getType()))
|
||||
{ // If item is type ConfigEntry
|
||||
if (!isAcceptableType(entry.getType()))
|
||||
{
|
||||
LOGGER.error("Invalid variable type at [" + (category.isEmpty() ? "" : category + ".") + field.getName() + "].");
|
||||
LOGGER.error("Type [" + entry.getType() + "] is not one of these types [" + acceptableInputs.toString() + "]");
|
||||
entries.remove(entries.size() - 1); // Delete the entry if it is invalid so the game can still run
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigCategory.class.isAssignableFrom(field.getType()))
|
||||
{ // If it's a category then init the stuff inside it and put it in the category list
|
||||
assert entry instanceof ConfigCategory;
|
||||
if (((ConfigCategory) entry).getDestination() == null)
|
||||
((ConfigCategory) entry).destination = entry.getNameWCategory();
|
||||
if (entry.get() != null)
|
||||
{
|
||||
initNestedClass(((ConfigCategory) entry).get(), ((ConfigCategory) entry).getDestination());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAcceptableType(Class<?> Clazz)
|
||||
{
|
||||
if (Clazz.isEnum())
|
||||
return true;
|
||||
return acceptableInputs.contains(Clazz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used for checking that all the lang files for the config exist
|
||||
*
|
||||
* @param onlyShowNew If disabled then it would basically remake the config lang
|
||||
* @param checkEnums Checks if all the lang for the enum's exist
|
||||
*/
|
||||
// This is just to re-format the lang or check if there is something in the lang that is missing
|
||||
public String generateLang(boolean onlyShowNew, boolean checkEnums)
|
||||
{
|
||||
ILangWrapper langWrapper = SingletonInjector.INSTANCE.get(ILangWrapper.class);
|
||||
List<Class<? extends Enum>> enumList = new ArrayList<>();
|
||||
|
||||
String generatedLang = "";
|
||||
|
||||
String starter = " \"";
|
||||
String separator = "\":\n \"";
|
||||
String ending = "\",\n";
|
||||
|
||||
for (AbstractConfigType<?, ?> entry : this.entries)
|
||||
{
|
||||
String entryPrefix = "lod.config." + entry.getNameWCategory();
|
||||
|
||||
if (checkEnums && entry.getType().isEnum() && !enumList.contains(entry.getType()))
|
||||
{ // Put it in an enum list to work with at the end
|
||||
enumList.add((Class<? extends Enum>) entry.getType());
|
||||
}
|
||||
if (!onlyShowNew || langWrapper.langExists(entryPrefix))
|
||||
{
|
||||
if (!ConfigLinkedEntry.class.isAssignableFrom(entry.getClass()))
|
||||
{ // If it is a linked item, dont generate the base lang
|
||||
generatedLang += starter
|
||||
+ entryPrefix
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix)
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
// Adds tooltips
|
||||
if (langWrapper.langExists(entryPrefix + ".@tooltip"))
|
||||
{
|
||||
generatedLang += starter
|
||||
+ entryPrefix + ".@tooltip"
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix + ".@tooltip")
|
||||
.replaceAll("\n", "\\\\n")
|
||||
.replaceAll("\"", "\\\\\"")
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!enumList.isEmpty())
|
||||
{
|
||||
generatedLang += "\n"; // Separate the main lang with the enum's
|
||||
|
||||
for (Class<? extends Enum> anEnum : enumList)
|
||||
{
|
||||
for (Object enumStr : new ArrayList<>(EnumSet.allOf(anEnum)))
|
||||
{
|
||||
String enumPrefix = "lod.config.enum." + anEnum.getSimpleName() + "." + enumStr.toString();
|
||||
|
||||
if (!onlyShowNew || langWrapper.langExists(enumPrefix))
|
||||
{
|
||||
generatedLang += starter
|
||||
+ enumPrefix
|
||||
+ separator
|
||||
+ langWrapper.getLang(enumPrefix)
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return generatedLang;
|
||||
}
|
||||
|
||||
/**
|
||||
What the config works with
|
||||
|
||||
Enum
|
||||
Boolean
|
||||
Byte
|
||||
Integer
|
||||
Double
|
||||
Short
|
||||
Long
|
||||
Float
|
||||
String
|
||||
|
||||
// Below, "T" should be a value from above
|
||||
List<T>
|
||||
ArrayList<T>
|
||||
Map<String, T>
|
||||
HashMap<String, T>
|
||||
*/
|
||||
public static final List<Class<?>> acceptableInputs = new ArrayList<Class<?>>() {{
|
||||
add(Boolean.class);
|
||||
add(Byte.class);
|
||||
add(Integer.class);
|
||||
add(Double.class);
|
||||
add(Short.class);
|
||||
add(Long.class);
|
||||
add(Float.class);
|
||||
add(String.class);
|
||||
|
||||
// TODO[CONFIG]: Check the type of these is valid
|
||||
add(List.class);
|
||||
add(ArrayList.class);
|
||||
add(Map.class);
|
||||
add(HashMap.class);
|
||||
}};
|
||||
|
||||
/** Disables the minimum and maximum of any variable */
|
||||
public boolean disableMinMax = false; // Very fun to use, but should always be disabled by default
|
||||
public final List<AbstractConfigType<?, ?>> entries = new ArrayList<>();
|
||||
|
||||
|
||||
public ConfigBase(String modID, String modName, Class<?> config, int configVersion) {
|
||||
LOGGER.info("Initialising config for " + modName);
|
||||
this.modID = modID;
|
||||
this.modName = modName;
|
||||
this.configVersion = configVersion;
|
||||
|
||||
initNestedClass(config, ""); // Init root category
|
||||
|
||||
// File handling (load from file)
|
||||
this.configFileINSTANCE = new ConfigFileHandling(this);
|
||||
this.configFileINSTANCE.loadFromFile();
|
||||
LOGGER.info("Config for " + modName + " initialised");
|
||||
}
|
||||
|
||||
private void initNestedClass(Class<?> config, String category) {
|
||||
// Put all the entries in entries
|
||||
|
||||
for (Field field : config.getFields()) {
|
||||
if (AbstractConfigType.class.isAssignableFrom(field.getType())) {
|
||||
try {
|
||||
entries.add((AbstractConfigType<?, ?>) field.get(field.getType()));
|
||||
} catch (IllegalAccessException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
AbstractConfigType<?, ?> entry = entries.get(entries.size() - 1);
|
||||
entry.category = category;
|
||||
entry.name = field.getName();
|
||||
entry.configBase = this;
|
||||
|
||||
if (ConfigEntry.class.isAssignableFrom(field.getType())) { // If item is type ConfigEntry
|
||||
if (!isAcceptableType(entry.getType())) {
|
||||
LOGGER.error("Invalid variable type at [" + (category.isEmpty() ? "" : category + ".") + field.getName() + "].");
|
||||
LOGGER.error("Type [" + entry.getType() + "] is not one of these types [" + acceptableInputs.toString() + "]");
|
||||
entries.remove(entries.size() -1); // Delete the entry if it is invalid so the game can still run
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigCategory.class.isAssignableFrom(field.getType())) { // If it's a category then init the stuff inside it and put it in the category list
|
||||
assert entry instanceof ConfigCategory;
|
||||
if (((ConfigCategory) entry).getDestination() == null)
|
||||
((ConfigCategory) entry).destination = entry.getNameWCategory();
|
||||
if (entry.get() != null) {
|
||||
initNestedClass(((ConfigCategory) entry).get(), ((ConfigCategory) entry).getDestination());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAcceptableType(Class<?> Clazz) {
|
||||
if (Clazz.isEnum())
|
||||
return true;
|
||||
return acceptableInputs.contains(Clazz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used for checking that all the lang files for the config exist
|
||||
*
|
||||
* @param onlyShowNew If disabled then it would basically remake the config lang
|
||||
* @param checkEnums Checks if all the lang for the enum's exist
|
||||
*/
|
||||
// This is just to re-format the lang or check if there is something in the lang that is missing
|
||||
public String generateLang(boolean onlyShowNew, boolean checkEnums) {
|
||||
ILangWrapper langWrapper = SingletonInjector.INSTANCE.get(ILangWrapper.class);
|
||||
List<Class<? extends Enum>> enumList = new ArrayList<>();
|
||||
|
||||
String generatedLang = "";
|
||||
|
||||
String starter = " \"";
|
||||
String separator = "\":\n \"";
|
||||
String ending = "\",\n";
|
||||
|
||||
for (AbstractConfigType<?, ?> entry: this.entries) {
|
||||
String entryPrefix = "lod.config."+entry.getNameWCategory();
|
||||
|
||||
if (checkEnums && entry.getType().isEnum() && !enumList.contains(entry.getType())) { // Put it in an enum list to work with at the end
|
||||
enumList.add((Class<? extends Enum>) entry.getType());
|
||||
}
|
||||
if (!onlyShowNew || langWrapper.langExists(entryPrefix)) {
|
||||
if (!ConfigLinkedEntry.class.isAssignableFrom(entry.getClass())) { // If it is a linked item, dont generate the base lang
|
||||
generatedLang += starter
|
||||
+ entryPrefix
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix)
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
// Adds tooltips
|
||||
if (langWrapper.langExists(entryPrefix+".@tooltip")) {
|
||||
generatedLang += starter
|
||||
+ entryPrefix+".@tooltip"
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix+".@tooltip")
|
||||
.replaceAll("\n", "\\\\n")
|
||||
.replaceAll("\"", "\\\\\"")
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!enumList.isEmpty()) {
|
||||
generatedLang += "\n"; // Separate the main lang with the enum's
|
||||
|
||||
for (Class<? extends Enum> anEnum: enumList) {
|
||||
for (Object enumStr: new ArrayList<>(EnumSet.allOf(anEnum))) {
|
||||
String enumPrefix = "lod.config.enum."+anEnum.getSimpleName()+"."+enumStr.toString();
|
||||
|
||||
if (!onlyShowNew || langWrapper.langExists(enumPrefix)) {
|
||||
generatedLang += starter
|
||||
+ enumPrefix
|
||||
+ separator
|
||||
+ langWrapper.getLang(enumPrefix)
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return generatedLang;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,59 +10,67 @@ import java.util.Map;
|
||||
* @version 2023-7-16
|
||||
*/
|
||||
// TODO: Should this be moved out of here into somewhere like the util section
|
||||
public class NumberUtil {
|
||||
// Is there no better way of doing this?
|
||||
public static Map<Class, Number> minValues = new HashMap<Class, Number>() {{
|
||||
put(Byte.class, Byte.MIN_VALUE);
|
||||
put(Short.class, Short.MIN_VALUE);
|
||||
put(Integer.class, Integer.MIN_VALUE);
|
||||
put(Long.class, Long.MIN_VALUE);
|
||||
put(Double.class, Double.MIN_VALUE);
|
||||
put(Float.class, Float.MIN_VALUE);
|
||||
}};
|
||||
public static Map<Class, Number> maxValues = new HashMap<Class, Number>() {{
|
||||
put(Byte.class, Byte.MAX_VALUE);
|
||||
put(Short.class, Short.MAX_VALUE);
|
||||
put(Integer.class, Integer.MAX_VALUE);
|
||||
put(Long.class, Long.MAX_VALUE);
|
||||
put(Double.class, Double.MAX_VALUE);
|
||||
put(Float.class, Float.MAX_VALUE);
|
||||
}};
|
||||
|
||||
public static Number getMinimum(Class c) {
|
||||
return minValues.get(c);
|
||||
}
|
||||
public static Number getMaximum(Class c) {
|
||||
return maxValues.get(c);
|
||||
}
|
||||
|
||||
/** Does a greater than (>) operator on any number */
|
||||
public static boolean greaterThan(Number a, Number b) {
|
||||
if (a.getClass() != b.getClass())
|
||||
return false;
|
||||
Class typeClass = a.getClass();
|
||||
|
||||
if (typeClass == Byte.class) return a.byteValue() > b.byteValue();
|
||||
if (typeClass == Short.class) return a.shortValue() > b.shortValue();
|
||||
if (typeClass == Integer.class) return a.intValue() > b.intValue();
|
||||
if (typeClass == Long.class) return a.longValue() > b.longValue();
|
||||
if (typeClass == Double.class) return a.doubleValue() > b.doubleValue();
|
||||
if (typeClass == Float.class) return a.floatValue() > b.floatValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Does a less than (<) operator on any number */
|
||||
public static boolean lessThan(Number a, Number b) {
|
||||
if (a.getClass() != b.getClass())
|
||||
return false;
|
||||
Class typeClass = a.getClass();
|
||||
|
||||
if (typeClass == Byte.class) return a.byteValue() < b.byteValue();
|
||||
if (typeClass == Short.class) return a.shortValue() < b.shortValue();
|
||||
if (typeClass == Integer.class) return a.intValue() < b.intValue();
|
||||
if (typeClass == Long.class) return a.longValue() < b.longValue();
|
||||
if (typeClass == Double.class) return a.doubleValue() < b.doubleValue();
|
||||
if (typeClass == Float.class) return a.floatValue() < b.floatValue();
|
||||
return false;
|
||||
}
|
||||
public class NumberUtil
|
||||
{
|
||||
// Is there no better way of doing this?
|
||||
public static Map<Class, Number> minValues = new HashMap<Class, Number>()
|
||||
{{
|
||||
put(Byte.class, Byte.MIN_VALUE);
|
||||
put(Short.class, Short.MIN_VALUE);
|
||||
put(Integer.class, Integer.MIN_VALUE);
|
||||
put(Long.class, Long.MIN_VALUE);
|
||||
put(Double.class, Double.MIN_VALUE);
|
||||
put(Float.class, Float.MIN_VALUE);
|
||||
}};
|
||||
public static Map<Class, Number> maxValues = new HashMap<Class, Number>()
|
||||
{{
|
||||
put(Byte.class, Byte.MAX_VALUE);
|
||||
put(Short.class, Short.MAX_VALUE);
|
||||
put(Integer.class, Integer.MAX_VALUE);
|
||||
put(Long.class, Long.MAX_VALUE);
|
||||
put(Double.class, Double.MAX_VALUE);
|
||||
put(Float.class, Float.MAX_VALUE);
|
||||
}};
|
||||
|
||||
public static Number getMinimum(Class c)
|
||||
{
|
||||
return minValues.get(c);
|
||||
}
|
||||
public static Number getMaximum(Class c)
|
||||
{
|
||||
return maxValues.get(c);
|
||||
}
|
||||
|
||||
/** Does a greater than (>) operator on any number */
|
||||
public static boolean greaterThan(Number a, Number b)
|
||||
{
|
||||
if (a.getClass() != b.getClass())
|
||||
return false;
|
||||
Class typeClass = a.getClass();
|
||||
|
||||
if (typeClass == Byte.class) return a.byteValue() > b.byteValue();
|
||||
if (typeClass == Short.class) return a.shortValue() > b.shortValue();
|
||||
if (typeClass == Integer.class) return a.intValue() > b.intValue();
|
||||
if (typeClass == Long.class) return a.longValue() > b.longValue();
|
||||
if (typeClass == Double.class) return a.doubleValue() > b.doubleValue();
|
||||
if (typeClass == Float.class) return a.floatValue() > b.floatValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Does a less than (<) operator on any number */
|
||||
public static boolean lessThan(Number a, Number b)
|
||||
{
|
||||
if (a.getClass() != b.getClass())
|
||||
return false;
|
||||
Class typeClass = a.getClass();
|
||||
|
||||
if (typeClass == Byte.class) return a.byteValue() < b.byteValue();
|
||||
if (typeClass == Short.class) return a.shortValue() < b.shortValue();
|
||||
if (typeClass == Integer.class) return a.intValue() < b.intValue();
|
||||
if (typeClass == Long.class) return a.longValue() < b.longValue();
|
||||
if (typeClass == Double.class) return a.doubleValue() < b.doubleValue();
|
||||
if (typeClass == Float.class) return a.floatValue() < b.floatValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,15 +14,15 @@ public class QuickRenderToggleConfigEventHandler
|
||||
|
||||
|
||||
/** private since we only ever need one handler at a time */
|
||||
private QuickRenderToggleConfigEventHandler()
|
||||
private QuickRenderToggleConfigEventHandler()
|
||||
{
|
||||
this.quickRenderChangeListener = new ConfigChangeListener<>(Config.Client.quickEnableRendering, (val) -> { Config.Client.Advanced.Debugging.rendererMode.set(Config.Client.quickEnableRendering.get() ? ERendererMode.DEFAULT : ERendererMode.DISABLED); });
|
||||
this.rendererModeChangeListener = new ConfigChangeListener<>(Config.Client.Advanced.Debugging.rendererMode, (val) -> { Config.Client.quickEnableRendering.set(Config.Client.Advanced.Debugging.rendererMode.get() != ERendererMode.DISABLED); });
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the UI only config based on what is set in the file. <br>
|
||||
* This should only be called once.
|
||||
* Set the UI only config based on what is set in the file. <br>
|
||||
* This should only be called once.
|
||||
*/
|
||||
public void setUiOnlyConfigValues()
|
||||
{
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ import java.util.TimerTask;
|
||||
/**
|
||||
* Listens to the config and will automatically
|
||||
* clear the current render cache if certain settings are changed. <br> <br>
|
||||
*
|
||||
*
|
||||
* Note: if additional settings should clear the render cache, add those to this listener, don't create a new listener
|
||||
*/
|
||||
public class RenderCacheConfigEventHandler implements IConfigListener
|
||||
@@ -31,11 +31,11 @@ public class RenderCacheConfigEventHandler implements IConfigListener
|
||||
|
||||
|
||||
/** private since we only ever need one handler at a time */
|
||||
private RenderCacheConfigEventHandler() { }
|
||||
private RenderCacheConfigEventHandler() { }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onConfigValueSet()
|
||||
{
|
||||
// confirm a setting was actually changed
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ public class ResetConfigEventHandler
|
||||
|
||||
|
||||
/** private since we only ever need one handler at a time */
|
||||
private ResetConfigEventHandler()
|
||||
private ResetConfigEventHandler()
|
||||
{
|
||||
this.configChangeListener = new ConfigChangeListener<>(Config.Client.ResetConfirmation.resetAllSettings, (resetSettings) -> { doStuff(resetSettings); });
|
||||
|
||||
|
||||
+17
-13
@@ -3,17 +3,21 @@ package com.seibel.distanthorizons.core.config.eventHandlers;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.config.listeners.IConfigListener;
|
||||
|
||||
public class UnsafeValuesConfigListener implements IConfigListener {
|
||||
public static UnsafeValuesConfigListener INSTANCE = new UnsafeValuesConfigListener();
|
||||
|
||||
@Override
|
||||
public void onConfigValueSet() {
|
||||
Config.Client.Advanced.Debugging.allowUnsafeValues.configBase.disableMinMax =
|
||||
Config.Client.Advanced.Debugging.allowUnsafeValues.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiModify() {
|
||||
|
||||
}
|
||||
public class UnsafeValuesConfigListener implements IConfigListener
|
||||
{
|
||||
public static UnsafeValuesConfigListener INSTANCE = new UnsafeValuesConfigListener();
|
||||
|
||||
@Override
|
||||
public void onConfigValueSet()
|
||||
{
|
||||
Config.Client.Advanced.Debugging.allowUnsafeValues.configBase.disableMinMax =
|
||||
Config.Client.Advanced.Debugging.allowUnsafeValues.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiModify()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user