Compare commits

..

1 Commits

Author SHA1 Message Date
cola98765 d5d46f92e5 do not transfer transparency to block below 2024-03-15 09:30:43 +00:00
348 changed files with 13923 additions and 20140 deletions
-3
View File
@@ -27,6 +27,3 @@ forge*changelog.txt
# Sqlite databases
*.sqlite
*.sqlite-journal
*.sqlite-shm
*.sqlite-wal
+1 -1
View File
@@ -3,7 +3,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id "java"
id "com.github.johnrengelman.shadow" version '8.1.1' apply false
id "com.github.johnrengelman.shadow" version '7.1.2' apply false
}
@@ -23,9 +23,7 @@ import com.seibel.distanthorizons.api.interfaces.events.IDhApiEventInjector;
import com.seibel.distanthorizons.api.interfaces.factories.IDhApiWrapperFactory;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.api.interfaces.override.worldGenerator.IDhApiWorldGeneratorOverrideRegister;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderObjectFactory;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderProxy;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
import com.seibel.distanthorizons.api.methods.override.DhApiWorldGeneratorOverrideRegister;
import com.seibel.distanthorizons.coreapi.ModInfo;
@@ -125,16 +123,10 @@ public class DhApi
/**
* Used to create wrappers for Minecraft objects needed by other Distant Horizons API methods.
* @since API 2.0.0
* @since API 1.1.0
*/
public static IDhApiWrapperFactory wrapperFactory = null;
/**
* Used to create custom renderable objects. <br>
* These objects can be added to the renderer in {@link IDhApiLevelWrapper}
* @since API 3.0.0
*/
public static IDhApiCustomRenderObjectFactory customRenderObjectFactory = null;
}
@@ -180,7 +172,7 @@ public class DhApi
* This version should be updated whenever non-breaking fixes are added to the Distant Horizons API.
* @since API 1.0.0
*/
public static int getApiPatchVersion() { return ModInfo.API_PATCH_VERSION; }
public static int getApiPatchVersion() { return ModInfo.API_PATH_VERSION; }
/**
* Returns the mod's semantic version number in the format: Major.Minor.Patch
@@ -206,7 +198,7 @@ public class DhApi
/**
* Returns true if the thread this method was called from is owned by Distant Horizons.
* @since API 2.0.0
* @since API 1.1.0
*/
public static boolean isDhThread() { return Thread.currentThread().getName().startsWith(ModInfo.THREAD_NAME_PREFIX); }
@@ -24,7 +24,7 @@ package com.seibel.distanthorizons.api.enums;
* CHUNK - Detail Level: 4, width 16 block, <br>
* REGION - Detail Level: 9, width 512 block <br> <br>
*
* Detail levels in Distant Horizons represent how large a LOD
* Detail levels in Distant Horizons represent how large a section (of either LODs or MC chunks)
* 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>
@@ -23,10 +23,9 @@ package com.seibel.distanthorizons.api.enums.config;
* NONE, <br>
* NON_COLLIDING, <br>
*
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiBlocksToAvoid
public enum EBlocksToAvoid
{
// Reminder:
// when adding items up the API minor version
@@ -37,6 +36,6 @@ public enum EDhApiBlocksToAvoid
public final boolean noCollision;
EDhApiBlocksToAvoid(boolean noCollision) { this.noCollision = noCollision; }
EBlocksToAvoid(boolean noCollision) { this.noCollision = noCollision; }
}
@@ -0,0 +1,56 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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;
/**
* CONSTANT <br>
* FREQUENT <br>
* NORMAL <br>
* RARE <br> <br>
*
* Determines how fast the buffers should be regenerated
*
* @author Leonardo Amato
* @version 9-25-2021
*/
@Deprecated // not currently in use, if the config this enum represents is re-implemented, the deprecated flag can be removed
public enum EBufferRebuildTimes
{
CONSTANT(0, 0, 0, 1),
FREQUENT(1000, 500, 2500, 1),
NORMAL(2000, 1000, 5000, 4),
RARE(5000, 2000, 10000, 16);
public final int playerMoveTimeout;
public final int renderedChunkTimeout;
public final int chunkChangeTimeout;
public final int playerMoveDistance;
EBufferRebuildTimes(int playerMoveTimeout, int renderedChunkTimeout, int chunkChangeTimeout, int playerMoveDistance)
{
this.playerMoveTimeout = playerMoveTimeout;
this.renderedChunkTimeout = renderedChunkTimeout;
this.chunkChangeTimeout = chunkChangeTimeout;
this.playerMoveDistance = playerMoveDistance;
}
}
@@ -1,101 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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;
/**
* UNCOMPRESSED <br>
* LZ4 <br>
* XZ <br><br>
*
* Note: speed and compression ratios are examples
* and should only be used for estimated comparisons.
*
* @version 2024-3-16
* @since API 2.0.0
*/
public enum EDhApiDataCompressionMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* Should only be used internally and for unit testing. <br><br>
*
* Read Speed: 1.64 MS / DTO <br>
* Write Speed: 12.44 MS / DTO <br>
* Compression ratio: 1.0 <br>
*/
@DisallowSelectingViaConfigGui
UNCOMPRESSED(0),
/**
* Extremely fast (often faster than uncompressed), but generally poor compression. <br><br>
*
* Read Speed: 1.85 MS / DTO <br>
* Write Speed: 9.46 MS / DTO <br>
* Compression ratio: 0.3638 <br>
*/
LZ4(1),
/*
* Decent speed and good compression. <br><br>
*
* Read Speed: 11.78 MS / DTO <br>
* Write Speed: 16.76 MS / DTO <br>
* Compression ratio: 0.2199 <br>
*/
//@Deprecated
//Z_STD(2),
/**
* Extremely slow, but very good compression. <br><br>
*
* Read Speed: 12.25 MS / DTO <br>
* Write Speed: 490.07 MS / DTO <br>
* Compression ratio: 0.1242 <br>
*/
LZMA2(3);
/** More stable than using the ordinal of the enum */
public final byte value;
EDhApiDataCompressionMode(int value) { this.value = (byte) value; }
/** @throws IllegalArgumentException if the value doesn't map to a value */
public static EDhApiDataCompressionMode getFromValue(byte value) throws IllegalArgumentException
{
EDhApiDataCompressionMode[] enumList = EDhApiDataCompressionMode.values();
for (int i = 0; i < enumList.length; i++)
{
if (enumList[i].value == value)
{
return enumList[i];
}
}
throw new IllegalArgumentException("No compression mode with the value ["+value+"]");
}
}
@@ -1,41 +0,0 @@
package com.seibel.distanthorizons.api.enums.config;
import com.seibel.distanthorizons.coreapi.ModInfo;
/**
* AUTO, <br>
* STABLE, <br>
* NIGHTLY, <br><br>
*
* @since API 2.1.0
* @version 2024-6-8
*/
public enum EDhApiUpdateBranch
{
AUTO,
STABLE,
NIGHTLY;
/**
* If the updateBranch value is {@link EDhApiUpdateBranch#AUTO}
* this method will convert it either to {@link EDhApiUpdateBranch#STABLE} or {@link EDhApiUpdateBranch#NIGHTLY}
* based on this jar's state. <Br><br>
*
* If updateBranch is {@link EDhApiUpdateBranch#STABLE} or {@link EDhApiUpdateBranch#NIGHTLY}
* it just returns.
*/
public static EDhApiUpdateBranch convertAutoToStableOrNightly(EDhApiUpdateBranch updateBranch)
{
if (updateBranch != EDhApiUpdateBranch.AUTO)
{
return updateBranch;
}
else
{
return ModInfo.IS_DEV_BUILD ? EDhApiUpdateBranch.NIGHTLY : EDhApiUpdateBranch.STABLE;
}
}
}
@@ -1,70 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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;
/**
* MERGE_SAME_BLOCKS <br>
* VISUALLY_EQUAL <br><br>
*
* @version 2024-3-27
* @since API 2.0.0
*/
public enum EDhApiWorldCompressionMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* Every block/biome change is recorded in the database. <br>
* This is what DH 2.0 and 2.0.1 all used by default and will store a lot of data.
*/
MERGE_SAME_BLOCKS(0),
/**
* Only visible block/biome changes are recorded in the database. <Br>
* Hidden blocks (IE ores) are ignored.
*/
VISUALLY_EQUAL(1);
/** More stable than using the ordinal of the enum */
public final byte value;
EDhApiWorldCompressionMode(int value) { this.value = (byte) value; }
public static EDhApiWorldCompressionMode getFromValue(byte value)
{
EDhApiWorldCompressionMode[] enumList = EDhApiWorldCompressionMode.values();
for (int i = 0; i < enumList.length; i++)
{
if (enumList[i].value == value)
{
return enumList[i];
}
}
throw new IllegalArgumentException("No lossy compression mode with the value ["+value+"]");
}
}
@@ -20,10 +20,9 @@
package com.seibel.distanthorizons.api.enums.config;
/**
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiGLErrorHandlingMode
public enum EGLErrorHandlingMode
{
IGNORE,
LOG,
@@ -0,0 +1,48 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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;
/**
* AUTO <br>
* Near_First <br>
* Far_First <br> <br>
*
* Determines which LODs should have priority when generating
* outside the normal view distance.
*
* @author Leonardo Amato
* @version 12-1-2021
*/
@Deprecated // not currently in use, if the config this enum represents is re-implemented, the deprecated flag can be removed
public enum EGenerationPriority
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** NEAR_FIRST when connected to servers and BALANCED when on single player */
AUTO,
NEAR_FIRST,
BALANCED,
FAR_FIRST
}
@@ -20,10 +20,9 @@
package com.seibel.distanthorizons.api.enums.config;
/**
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiGlProfileMode
public enum EGlProfileMode
{
CORE,
COMPAT,
@@ -23,14 +23,15 @@ package com.seibel.distanthorizons.api.enums.config;
* AUTO, <br>
* BUFFER_STORAGE, <br>
* SUB_DATA, <br>
* BUFFER_MAPPING, <br>
* DATA <br>
*
* @author Leetom
* @author James Seibel
* @version 2024-4-6
* @since API 3.0.0
* @version 2022-7-2
* @since API 1.0.0
*/
public enum EDhApiGpuUploadMethod
public enum EGpuUploadMethod
{
/** Picks the best option based on the GPU the user has. */
AUTO(false, false),
@@ -48,10 +49,7 @@ public enum EDhApiGpuUploadMethod
* 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.
*
* @deprecated not currently supported
*/
@Deprecated
BUFFER_MAPPING(true, false),
/** Fast rendering but may stutter when uploading. */
@@ -62,7 +60,7 @@ public enum EDhApiGpuUploadMethod
public final boolean useEarlyMapping;
public final boolean useBufferStorage;
EDhApiGpuUploadMethod(boolean useEarlyMapping, boolean useBufferStorage)
EGpuUploadMethod(boolean useEarlyMapping, boolean useBufferStorage)
{
this.useEarlyMapping = useEarlyMapping;
this.useBufferStorage = useBufferStorage;
@@ -26,10 +26,9 @@ package com.seibel.distanthorizons.api.enums.config;
* HIGH <br>
* UNLIMITED <br>
*
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiHorizontalQuality
public enum EHorizontalQuality
{
// Reminder:
// when adding items up the API minor version
@@ -43,16 +42,17 @@ public enum EDhApiHorizontalQuality
LOWEST(2.0f, 4),
LOW(2.0f, 8),
MEDIUM(2.0f, 12),
HIGH(2.2f, 16),
EXTREME(2.4f, 32),
;
HIGH(2.2f, 24),
EXTREME(2.4f, 64),
UNLIMITED(-1, -1);
public final double quadraticBase;
public final int distanceUnitInBlocks;
EDhApiHorizontalQuality(double quadraticBase, int distanceUnitInBlocks)
EHorizontalQuality(double quadraticBase, int distanceUnitInBlocks)
{
this.quadraticBase = quadraticBase;
this.distanceUnitInBlocks = distanceUnitInBlocks;
@@ -20,21 +20,21 @@
package com.seibel.distanthorizons.api.enums.config;
/**
* AS_GRASS <br>
* FADE_TO_DIRT <br>
* AS_DIRT <br>
* DISTANT_HORIZONS, <br>
* MINECRAFT,
*
* @since API 2.0.0
* @version 2024-4-7
* @author Leetom
* @version 2023-6-7
* @since API 1.0.0
*/
public enum EDhApiGrassSideRendering
public enum ELightGenerationMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
AS_GRASS,
FADE_TO_DIRT,
AS_DIRT;
DISTANT_HORIZONS,
MINECRAFT
}
@@ -20,33 +20,27 @@
package com.seibel.distanthorizons.api.enums.config;
/**
* AUTO <br>
* ENABLED <br>
* DISABLED <br>
* MINECRAFT <br>
* OLD_LIGHTING <br>
* NONE <br>
*
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiLodShading
public enum ELodShading
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** Uses Minecraft's shading for LODs */
MINECRAFT,
/**
* Uses Minecraft's shading for LODs. <Br>
* This means if Minecraft's shading is disabled DH's shading will be as well.
*/
AUTO,
/**
* Simulates Minecraft's shading. <Br>
* Simulates Minecraft's shading.
* This is most useful for shaders that disable Minecraft's shading
* but still require shading on LODs.
*/
ENABLED,
OLD_LIGHTING,
/** LODs will have no shading */
DISABLED;
NONE;
}
@@ -22,10 +22,9 @@ package com.seibel.distanthorizons.api.enums.config;
import org.apache.logging.log4j.Level;
/**
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiLoggerMode
public enum ELoggerMode
{
DISABLED(Level.OFF, Level.OFF),
LOG_ALL_TO_FILE(Level.ALL, Level.OFF),
@@ -41,14 +40,11 @@ public enum EDhApiLoggerMode
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;
EDhApiLoggerMode(Level levelForFile, Level levelForChat)
ELoggerMode(Level levelForFile, Level levelForChat)
{
this.levelForFile = levelForFile;
this.levelForChat = levelForChat;
}
}
@@ -33,10 +33,10 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
*
* @author James Seibel
* @author Leonardo Amato
* @since API 2.0.0
* @version 2024-4-6
* @version 2023-6-14
* @since API 1.0.0
*/
public enum EDhApiMaxHorizontalResolution
public enum EMaxHorizontalResolution
{
/** render 256 LODs for each chunk */
BLOCK(16, 0),
@@ -84,12 +84,12 @@ public enum EDhApiMaxHorizontalResolution
* 2nd dimension: An array of all LodDetails that are less than or <br>
* equal to that detailLevel
*/
private static EDhApiMaxHorizontalResolution[][] lowerDetailArrays;
private static EMaxHorizontalResolution[][] lowerDetailArrays;
EDhApiMaxHorizontalResolution(int newLengthCount, int newDetailLevel)
EMaxHorizontalResolution(int newLengthCount, int newDetailLevel)
{
this.detailLevel = (byte) newDetailLevel;
this.dataPointLengthCount = newLengthCount;
@@ -129,20 +129,20 @@ public enum EDhApiMaxHorizontalResolution
* Returns an array of all LodDetails that have a detail level
* that is less than or equal to the given LodDetail
*/
public static EDhApiMaxHorizontalResolution[] getSelfAndLowerDetails(EDhApiMaxHorizontalResolution detail)
public static EMaxHorizontalResolution[] getSelfAndLowerDetails(EMaxHorizontalResolution detail)
{
if (lowerDetailArrays == null)
{
// run first time setup
lowerDetailArrays = new EDhApiMaxHorizontalResolution[EDhApiMaxHorizontalResolution.values().length][];
lowerDetailArrays = new EMaxHorizontalResolution[EMaxHorizontalResolution.values().length][];
// go through each LodDetail
for (EDhApiMaxHorizontalResolution currentDetail : EDhApiMaxHorizontalResolution.values())
for (EMaxHorizontalResolution currentDetail : EMaxHorizontalResolution.values())
{
ArrayList<EDhApiMaxHorizontalResolution> lowerDetails = new ArrayList<>();
ArrayList<EMaxHorizontalResolution> lowerDetails = new ArrayList<>();
// find the details lower than currentDetail
for (EDhApiMaxHorizontalResolution compareDetail : EDhApiMaxHorizontalResolution.values())
for (EMaxHorizontalResolution compareDetail : EMaxHorizontalResolution.values())
{
if (currentDetail.detailLevel <= compareDetail.detailLevel)
{
@@ -154,7 +154,7 @@ public enum EDhApiMaxHorizontalResolution
Collections.sort(lowerDetails);
Collections.reverse(lowerDetails);
lowerDetailArrays[currentDetail.detailLevel] = lowerDetails.toArray(new EDhApiMaxHorizontalResolution[lowerDetails.size()]);
lowerDetailArrays[currentDetail.detailLevel] = lowerDetails.toArray(new EMaxHorizontalResolution[lowerDetails.size()]);
}
}
@@ -162,9 +162,9 @@ public enum EDhApiMaxHorizontalResolution
}
/** Returns what detail level should be used at a given distance and maxDistance. */
public static EDhApiMaxHorizontalResolution getDetailForDistance(EDhApiMaxHorizontalResolution maxDetailLevel, int distance, int maxDistance)
public static EMaxHorizontalResolution getDetailForDistance(EMaxHorizontalResolution maxDetailLevel, int distance, int maxDistance)
{
EDhApiMaxHorizontalResolution[] lowerDetails = getSelfAndLowerDetails(maxDetailLevel);
EMaxHorizontalResolution[] lowerDetails = getSelfAndLowerDetails(maxDetailLevel);
int distanceBetweenDetails = maxDistance / lowerDetails.length;
int index = MathUtil.clamp(0, distance / distanceBetweenDetails, lowerDetails.length - 1);
@@ -0,0 +1,51 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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;
/**
* NONE <br>
* LIGHT <br>
* MEDIUM <br>
* HEAVY <br>
*
* CUSTOM <br>
*
* @since API 1.0.0
* @deprecated will be removed when DH updates to MC 1.21 <br>
* After removal a float value will be used to control overdraw instead.
*/
@Deprecated
public enum EOverdrawPrevention
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NONE,
LIGHT,
MEDIUM,
HEAVY,
/**
* Should not be passed in. <br>
* Is returned if the overdraw value doesn't match any of the enums defined here.
*/
CUSTOM;
}
@@ -22,7 +22,6 @@ package com.seibel.distanthorizons.api.enums.config;
/**
* NAME_ONLY, <br>
* IP_ONLY, <br>
* NAME_IP, <br>
* NAME_IP_PORT, <br>
* NAME_IP_PORT_MC_VERSION, <br> <br>
@@ -30,10 +29,10 @@ package com.seibel.distanthorizons.api.enums.config;
* Determines how the multiplayer folders should be named.
*
* @author James Seibel
* @since API 2.0.0
* @version 2024-4-6
* @version 2022-7-1
* @since API 1.0.0
*/
public enum EDhApiServerFolderNameMode
public enum EServerFolderNameMode
{
// Reminder:
// when adding items up the API minor version
@@ -43,9 +42,6 @@ public enum EDhApiServerFolderNameMode
/** Only use the server name */
NAME_ONLY,
/** Only use the server IP */
IP_ONLY,
/**
* {SERVER_NAME} IP {IP} <br>
* Example: Minecraft Server IP 192.168.1.40
@@ -0,0 +1,7 @@
package com.seibel.distanthorizons.api.enums.config;
public enum EUpdateBranch
{
STABLE,
NIGHTLY
}
@@ -28,11 +28,10 @@ package com.seibel.distanthorizons.api.enums.config;
* the vanilla Minecraft terrain.
*
* @author James Seibel
* @since API 2.0.0
* @version 2024-4-6
* @version 2022-6-30
*/
@Deprecated // not currently in use, if the config this enum represents is re-implemented, the deprecated flag can be removed
public enum EDhApiVanillaOverdraw
public enum EVanillaOverdraw
{
// Reminder:
// when adding items up the API minor version
@@ -29,25 +29,23 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
* EXTREME <br>
*
* @author Leonardo Amato
* @version 2024-4-6
* @since API 2.0.0
* @version 2023-2-5
* @since API 1.0.0
*/
public enum EDhApiVerticalQuality
public enum EVerticalQuality
{
HEIGHT_MAP( new int[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
LOW( new int[]{4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1}),
MEDIUM( new int[]{6, 4, 3, 3, 3, 3, 3, 2, 2, 2, 1}),
HIGH( new int[]{16, 8, 4, 3, 3, 3, 3, 3, 3, 3, 1}),
VERY_HIGH( new int[]{32, 16, 8, 4, 4, 3, 3, 3, 3, 3, 1}),
EXTREME( new int[]{64, 32, 8, 4, 4, 3, 3, 3, 3, 3, 1}),
PIXEL_ART( new int[]{512, 64, 16, 8, 4, 3, 3, 3, 3, 3, 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;
EDhApiVerticalQuality(int[] maxVerticalData) { this.maxVerticalData = maxVerticalData; }
EVerticalQuality(int[] maxVerticalData) { this.maxVerticalData = maxVerticalData; }
@@ -30,10 +30,9 @@ import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui
* HIGH, <br>
* EXTREME, <br>
*
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiQualityPreset
public enum EQualityPreset
{
// Reminder:
// when adding items up the API minor version
@@ -29,10 +29,9 @@ import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui
* BALANCED, <br>
* AGGRESSIVE, <br>
*
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiThreadPreset
public enum EThreadPreset
{
// Reminder:
// when adding items up the API minor version
@@ -45,6 +44,8 @@ public enum EDhApiThreadPreset
LOW_IMPACT,
BALANCED,
AGGRESSIVE,
// temporarily removed due to stability concerns
I_PAID_FOR_THE_WHOLE_CPU,
}
@@ -28,10 +28,10 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author Leetom
* @author James Seibel
* @version 2024-4-6
* @since API 2.0.0
* @version 2023-6-7
* @since API 1.0.0
*/
public enum EDhApiDebugRendering
public enum EDebugRendering
{
// Reminder:
// when adding items up the API minor version
@@ -44,6 +44,10 @@ public enum EDhApiDebugRendering
/** LOD colors are based on their detail */
SHOW_DETAIL,
@Deprecated
/** LOD colors are based on their gen mode. */
SHOW_GENMODE,
/** Block Materials are often used by Iris shaders to determine how LODs should be rendered */
SHOW_BLOCK_MATERIAL,
@@ -54,7 +58,7 @@ public enum EDhApiDebugRendering
SHOW_RENDER_SOURCE_FLAG;
public static EDhApiDebugRendering next(EDhApiDebugRendering type)
public static EDebugRendering next(EDebugRendering type)
{
switch (type)
{
@@ -71,7 +75,7 @@ public enum EDhApiDebugRendering
}
}
public static EDhApiDebugRendering previous(EDhApiDebugRendering type)
public static EDebugRendering previous(EDebugRendering type)
{
switch (type)
{
@@ -80,6 +84,8 @@ public enum EDhApiDebugRendering
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;
@@ -1,68 +0,0 @@
package com.seibel.distanthorizons.api.enums.rendering;
/**
* contains the indices used by shaders to determine
* how different block types should be rendered. <br><br>
*
* UNKNOWN, <br>
* LEAVES, <br>
* STONE, <br>
* WOOD, <br>
* METAL, <br>
* DIRT, <br>
* LAVA, <br>
* DEEPSLATE, <br>
* SNOW, <br>
* SAND, <br>
* TERRACOTTA, <br>
* NETHER_STONE, <br>
* WATER, <br>
* GRASS, <br>
* AIR, <br>
* ILLUMINATED, <br>
*
* @author IMS
* @author James Seibel
* @since API 3.0.0
* @version 2024-7-11
*/
public enum EDhApiBlockMaterial
{
UNKNOWN(0),
LEAVES(1),
STONE(2),
WOOD(3),
METAL(4),
DIRT(5),
LAVA(6),
DEEPSLATE(7),
SNOW(8),
SAND(9),
TERRACOTTA(10),
NETHER_STONE(11),
WATER(12),
GRASS(13),
/** shouldn't normally be needed, but just in case */
AIR(14),
ILLUMINATED(15); // Max value
public final byte index;
EDhApiBlockMaterial(int index) { this.index = (byte)index;}
public static EDhApiBlockMaterial getFromIndex(int index)
{
for(EDhApiBlockMaterial material : EDhApiBlockMaterial.values())
{
if (material.index == index)
{
return material;
}
}
return EDhApiBlockMaterial.UNKNOWN;
}
}
@@ -7,7 +7,7 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author James Seibel
* @version 2024-1-30
* @since API 2.0.0
* @since API 1.1.0
*/
public enum EDhApiRenderPass
{
@@ -24,10 +24,10 @@ package com.seibel.distanthorizons.api.enums.rendering;
* USE_SKY_COLOR, <br>
*
* @author James Seibel
* @version 2024-4-6
* @since API 2.0.0
* @version 2022-6-9
* @since API 1.0.0
*/
public enum EDhApiFogColorMode
public enum EFogColorMode
{
// Reminder:
// when adding items: up the API minor version
@@ -44,5 +44,4 @@ public enum EDhApiFogColorMode
* https://www.curseforge.com/minecraft/mc-mods/clear-skies-forge-port
*/
USE_SKY_COLOR,
}
@@ -0,0 +1,40 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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;
/**
* NEAR, <br>
* FAR, <br>
* NEAR_AND_FAR <br>
*
* @author James Seibel
* @version 2022-6-2
* @since API 1.0.0
*/
public enum EFogDistance
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NEAR,
FAR,
NEAR_AND_FAR
}
@@ -25,10 +25,10 @@ package com.seibel.distanthorizons.api.enums.rendering;
* FOG_DISABLED <br>
*
* @author James Seibel
* @since API 2.0.0
* @version 2022-6-2
* @since API 1.0.0
*/
public enum EDhApiFogDrawMode
public enum EFogDrawMode
{
// Reminder:
// when adding items up the API minor version
@@ -26,9 +26,9 @@ package com.seibel.distanthorizons.api.enums.rendering;
*
* @author Leetom
* @version 2022-6-30
* @since API 2.0.0
* @since API 1.0.0
*/
public enum EDhApiFogFalloff
public enum EFogFalloff
{
// Reminder:
// when adding items up the API minor version
@@ -38,5 +38,5 @@ public enum EDhApiFogFalloff
LINEAR,
EXPONENTIAL,
EXPONENTIAL_SQUARED,
// TEXTURE_BASED, // TODO: Impl this
}
@@ -32,10 +32,10 @@ package com.seibel.distanthorizons.api.enums.rendering;
* AVERAGE <br>
*
* @author Leetom
* @version 2024-4-6
* @since API 2.0.0
* @version 2022-4-14
* @since API 1.0.0
*/
public enum EDhApiHeightFogMixMode
public enum EHeightFogMixMode
{
BASIC,
IGNORE_HEIGHT,
@@ -28,10 +28,10 @@ package com.seibel.distanthorizons.api.enums.rendering;
* ABOVE_AND_BELOW_SET_HEIGHT, <br>
*
* @author Leetom
* @version 2024-4-6
* @since API 2.0.0
* @version 6-30-2022
* @since API 1.0.0
*/
public enum EDhApiHeightFogMode
public enum EHeightFogMode
{
// Reminder:
// when adding items up the API minor version
@@ -49,7 +49,7 @@ public enum EDhApiHeightFogMode
public final boolean above;
public final boolean below;
EDhApiHeightFogMode(boolean basedOnCamera, boolean above, boolean below)
EHeightFogMode(boolean basedOnCamera, boolean above, boolean below)
{
this.basedOnCamera = basedOnCamera;
this.above = above;
@@ -24,10 +24,10 @@ package com.seibel.distanthorizons.api.enums.rendering;
* Debug <br>
* Disabled <br>
*
* @since API 2.0.0
* @version 2024-4-6
* @version 2022-6-2
* @since API 1.0.0
*/
public enum EDhApiRendererMode
public enum ERendererMode
{
// Reminder:
// when adding items up the API minor version
@@ -40,7 +40,7 @@ public enum EDhApiRendererMode
/** Used by the config GUI to cycle through the available rendering options */
public static EDhApiRendererMode next(EDhApiRendererMode type)
public static ERendererMode next(ERendererMode type)
{
switch (type)
{
@@ -54,7 +54,7 @@ public enum EDhApiRendererMode
}
/** Used by the config GUI to cycle through the available rendering options */
public static EDhApiRendererMode previous(EDhApiRendererMode type)
public static ERendererMode previous(ERendererMode type)
{
switch (type)
{
@@ -24,10 +24,9 @@ package com.seibel.distanthorizons.api.enums.rendering;
* FAKE, <br>
* COMPLETE, <br>
*
* @since API 2.0.0
* @version 2024-4-6
* @since API 1.0.0
*/
public enum EDhApiTransparency
public enum ETransparency
{
// Reminder:
// when adding items up the API minor version
@@ -41,7 +40,7 @@ public enum EDhApiTransparency
public final boolean transparencyEnabled;
public final boolean fakeTransparencyEnabled;
EDhApiTransparency(boolean transparencyEnabled, boolean fakeTransparencyEnabled)
ETransparency(boolean transparencyEnabled, boolean fakeTransparencyEnabled)
{
this.transparencyEnabled = transparencyEnabled;
this.fakeTransparencyEnabled = fakeTransparencyEnabled;
@@ -31,7 +31,7 @@ import java.util.function.Consumer;
*
* @author Builderb0y, James Seibel
* @version 2023-12-21
* @since API 2.0.0
* @since API 1.1.0
*/
public enum EDhApiWorldGeneratorReturnType
{
@@ -40,7 +40,7 @@ public enum EDhApiWorldGeneratorReturnType
* {@link IDhApiWorldGenerator#generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer)}
* will be used when generating terrain.
*
* @since API 2.0.0
* @since API 1.1.0
*/
VANILLA_CHUNKS,
@@ -49,7 +49,7 @@ public enum EDhApiWorldGeneratorReturnType
* {@link IDhApiWorldGenerator#generateApiChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer)}
* will be used when generating terrain.
*
* @since API 2.0.0
* @since API 1.1.0
*/
API_CHUNKS;
@@ -19,7 +19,6 @@
package com.seibel.distanthorizons.api.interfaces.block;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
/**
@@ -31,25 +30,12 @@ import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
*/
public interface IDhApiBlockStateWrapper extends IDhApiUnsafeWrapper
{
/** @since API 1.0.0 */
boolean isAir();
/** @since API 1.0.0 */
boolean isSolid();
/** @since API 1.0.0 */
boolean isLiquid();
/**
* Returns the full serialized form of the given block
* as defined by DH's serialization methods.
* @since API 3.0.0
*/
String getSerialString();
/**
* Returns the byte value representing the {@link EDhApiBlockMaterial} enum.
* @see EDhApiBlockMaterial
* @since API 3.0.0
*/
byte getMaterialId();
// TODO:
// boolean hasNoCollision();
// boolean noFaceIsFullFace();
}
@@ -36,6 +36,7 @@ public interface IDhApiConfig
IDhApiWorldGenerationConfig worldGenerator();
IDhApiMultiplayerConfig multiplayer();
IDhApiMultiThreadingConfig multiThreading();
IDhApiGpuBuffersConfig gpuBuffers();
// note: DON'T add the Auto Updater to this API. We only want the user's to have the ability to control when things are downloaded to their machines.
//IDhApiLoggingConfig logging(); // TODO implement
IDhApiDebuggingConfig debugging();
@@ -47,7 +47,7 @@ public interface IDhApiConfigValue<T>
* Returns the value of the config if it was set by the API.
* Returns null if the config hasn't been set by the API.
*
* @since API 2.0.0
* @since API 1.1.0
*/
T getApiValue();
@@ -68,7 +68,7 @@ public interface IDhApiConfigValue<T>
* use the value set in the config menu.
*
* @return true if the value was set, false otherwise.
* @since API 2.0.0
* @since API 1.1.0
*/
boolean clearValue();
@@ -19,6 +19,7 @@
package com.seibel.distanthorizons.api.interfaces.config.both;
import com.seibel.distanthorizons.api.enums.config.ELightGenerationMode;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
@@ -19,6 +19,9 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.enums.rendering.EFogColorMode;
import com.seibel.distanthorizons.api.enums.rendering.EFogDistance;
import com.seibel.distanthorizons.api.enums.rendering.EFogDrawMode;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
@@ -19,7 +19,7 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiDebugRendering;
import com.seibel.distanthorizons.api.enums.rendering.EDebugRendering;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
@@ -33,7 +33,7 @@ import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
public interface IDhApiDebuggingConfig extends IDhApiConfigGroup
{
/** Can be used to debug the standard fake chunk rendering. */
IDhApiConfigValue<EDhApiDebugRendering> debugRendering();
IDhApiConfigValue<EDebugRendering> debugRendering();
/** If enabled debug keybindings can be used. */
IDhApiConfigValue<Boolean> debugKeybindings();
@@ -19,7 +19,8 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogFalloff;
import com.seibel.distanthorizons.api.enums.rendering.EFogFalloff;
import com.seibel.distanthorizons.api.enums.rendering.*;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
@@ -63,7 +64,7 @@ public interface IDhApiFarFogConfig extends IDhApiConfigGroup
IDhApiConfigValue<Double> farFogMaxThickness();
/** Defines how the fog changes in thickness. */
IDhApiConfigValue<EDhApiFogFalloff> farFogFalloff();
IDhApiConfigValue<EFogFalloff> farFogFalloff();
/** Defines the fog density. */
IDhApiConfigValue<Double> farFogDensity();
@@ -19,8 +19,10 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogDrawMode;
import com.seibel.distanthorizons.api.enums.rendering.EFogColorMode;
import com.seibel.distanthorizons.api.enums.rendering.EFogDistance;
import com.seibel.distanthorizons.api.enums.rendering.EFogDrawMode;
import com.seibel.distanthorizons.api.enums.rendering.*;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
@@ -56,11 +58,14 @@ public interface IDhApiFogConfig extends IDhApiConfigGroup
// basic fog settings //
//====================//
/** Defines at what distance fog is rendered on fake chunks. */
IDhApiConfigValue<EFogDistance> distance();
/** Should be used to enable/disable fog rendering. */
IDhApiConfigValue<EDhApiFogDrawMode> drawMode();
IDhApiConfigValue<EFogDrawMode> drawMode();
/** Can be used to enable support with mods that change vanilla MC's fog color. */
IDhApiConfigValue<EDhApiFogColorMode> color();
IDhApiConfigValue<EFogColorMode> color();
/**
* If enabled attempts to disable vanilla MC's fog on real chunks. <br>
@@ -19,28 +19,30 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.enums.config.EGpuUploadMethod;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
/**
* Distant Horizons' generic rendering configuration. <br><br>
* Distant Horizons' OpenGL buffer configuration.
*
* @author James Seibel
* @version 2024-7-11
* @since API 3.0.0
* @version 2023-6-14
* @since API 1.0.0
*/
public interface IDhApiGenericRenderingConfig extends IDhApiConfigGroup
public interface IDhApiGpuBuffersConfig extends IDhApiConfigGroup
{
/**
* If enabled DH will render generic objects into its terrain pass. <br>
* This includes: clouds, beacons, and API added objects.
/** Defines how geometry data is uploaded to the GPU. */
IDhApiConfigValue<EGpuUploadMethod> gpuUploadMethod();
/**
* Defines how long we should wait after uploading one
* Megabyte of geometry data to the GPU before uploading
* the next Megabyte of data. <br>
* This can be set to a non-zero number to reduce stuttering caused by
* uploading buffers to the GPU.
*/
IDhApiConfigValue<Boolean> renderingEnabled();
/** If enabled DH will render beacon beams. */
IDhApiConfigValue<Boolean> beaconRenderingEnabled();
/** If enabled DH will render clouds. */
IDhApiConfigValue<Boolean> cloudRenderingEnabled();
IDhApiConfigValue<Integer> gpuUploadPerMegabyteInMilliseconds();
}
@@ -20,8 +20,9 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.enums.config.*;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRendererMode;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiTransparency;
import com.seibel.distanthorizons.api.enums.config.*;
import com.seibel.distanthorizons.api.enums.rendering.ERendererMode;
import com.seibel.distanthorizons.api.enums.rendering.ETransparency;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
@@ -41,7 +42,6 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
IDhApiFogConfig fog();
IDhApiAmbientOcclusionConfig ambientOcclusion();
IDhApiNoiseTextureConfig noiseTexture();
IDhApiGenericRenderingConfig genericRendering();
@@ -68,7 +68,7 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
*
* Changing this config also changes {@link IDhApiGraphicsConfig#renderingEnabled()}'s value.
*/
IDhApiConfigValue<EDhApiRendererMode> renderingMode();
IDhApiConfigValue<ERendererMode> renderingMode();
@@ -77,18 +77,18 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
//==================//
/** Defines how detailed fake chunks are in the horizontal direction */
IDhApiConfigValue<EDhApiMaxHorizontalResolution> maxHorizontalResolution();
IDhApiConfigValue<EMaxHorizontalResolution> maxHorizontalResolution();
/** Defines how detailed fake chunks are in the vertical direction */
IDhApiConfigValue<EDhApiVerticalQuality> verticalQuality();
IDhApiConfigValue<EVerticalQuality> verticalQuality();
/** Modifies the quadratic function fake chunks use for horizontal quality drop-off. */
IDhApiConfigValue<EDhApiHorizontalQuality> horizontalQuality();
IDhApiConfigValue<EHorizontalQuality> horizontalQuality();
IDhApiConfigValue<EDhApiTransparency> transparency();
IDhApiConfigValue<ETransparency> transparency();
/** Defines what blocks won't be rendered as LODs. */
IDhApiConfigValue<EDhApiBlocksToAvoid> blocksToAvoid();
IDhApiConfigValue<EBlocksToAvoid> blocksToAvoid();
/**
* Defines if the color of avoided blocks will color the block below them. <Br>
@@ -112,6 +112,17 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
// advanced graphic settings //
//===========================//
/**
* Sets the distance used by the near clip plane to reduce
* overdraw. <br>
* Disabling this reduces holes in the world due to the near clip plane
* being too close to the camera and the terrain not being covered by vanilla terrain.
*
* @deprecated Use {@link IDhApiGraphicsConfig#overdrawPreventionRadius()} instead.
*/
@Deprecated
IDhApiConfigValue<EOverdrawPrevention> overdrawPrevention();
/**
* Sets the radius used by the near clip shader to reduce
* overdraw. <br>
@@ -122,7 +133,7 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
* Setting this to 0 will reduce/prevent holes in the world due to clipping to close to the camera
* but may cause overdraw issues with transparent or non-full blocks.
*
* @since API 2.0.0
* @since API 1.1.0
*/
IDhApiConfigValue<Double> overdrawPreventionRadius();
@@ -159,9 +170,9 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
/**
* Determines how LODs should be shaded.
*
* @since API 2.0.0
* @since API 1.1.0
*/
IDhApiConfigValue<EDhApiLodShading> lodShading();
IDhApiConfigValue<ELodShading> lodShading();
/**
* Sets whether LODs outside the view frustum culling will
@@ -172,7 +183,7 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
* start/stop rendering incorrectly based on the camera direction,
* but will also reduce FPS.
*
* @since API 2.0.0
* @since API 1.1.0
* @see IDhApiGraphicsConfig#disableShadowFrustumCulling()
*/
IDhApiConfigValue<Boolean> disableFrustumCulling();
@@ -184,7 +195,7 @@ public interface IDhApiGraphicsConfig extends IDhApiConfigGroup
*
* Disable this if shadows render incorrectly.
*
* @since API 2.0.0
* @since API 1.1.0
* @see IDhApiGraphicsConfig#disableFrustumCulling()
*/
IDhApiConfigValue<Boolean> disableShadowFrustumCulling();
@@ -19,9 +19,9 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogFalloff;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMode;
import com.seibel.distanthorizons.api.enums.rendering.EFogFalloff;
import com.seibel.distanthorizons.api.enums.rendering.EHeightFogMixMode;
import com.seibel.distanthorizons.api.enums.rendering.EHeightFogMode;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
@@ -40,10 +40,10 @@ public interface IDhApiHeightFogConfig extends IDhApiConfigGroup
{
/** Defines how the height fog mixes. */
IDhApiConfigValue<EDhApiHeightFogMixMode> heightFogMixMode();
IDhApiConfigValue<EHeightFogMixMode> heightFogMixMode();
/** Defines how the height fog is drawn relative to the camera or world. */
IDhApiConfigValue<EDhApiHeightFogMode> heightFogMode();
IDhApiConfigValue<EHeightFogMode> heightFogMode();
/**
* Defines the height fog's base height if {@link IDhApiHeightFogConfig#heightFogMode()}
@@ -64,7 +64,7 @@ public interface IDhApiHeightFogConfig extends IDhApiConfigGroup
IDhApiConfigValue<Double> heightFogMaxThickness();
/** Defines how the height fog changes in thickness. */
IDhApiConfigValue<EDhApiFogFalloff> heightFogFalloff();
IDhApiConfigValue<EFogFalloff> heightFogFalloff();
/** Defines the height fog's density. */
IDhApiConfigValue<Double> heightFogDensity();
@@ -20,7 +20,7 @@
package com.seibel.distanthorizons.api.interfaces.config.client;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue;
import com.seibel.distanthorizons.api.enums.config.EDhApiServerFolderNameMode;
import com.seibel.distanthorizons.api.enums.config.EServerFolderNameMode;
import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigGroup;
/**
@@ -37,7 +37,7 @@ public interface IDhApiMultiplayerConfig extends IDhApiConfigGroup
* Defines how multiplayer server folders are named. <br>
* Note: Changing this while connected to a multiplayer world will cause undefined behavior!
*/
IDhApiConfigValue<EDhApiServerFolderNameMode> folderSavingMode();
IDhApiConfigValue<EServerFolderNameMode> folderSavingMode();
/**
* Defines the necessary similarity (as a percent) that two potential levels
@@ -1,21 +0,0 @@
package com.seibel.distanthorizons.api.interfaces.data;
/**
* Can be used to drastically speed up repeat read operations in {@link IDhApiTerrainDataRepo}.
*
* @see IDhApiTerrainDataRepo
*
* @author James Seibel
* @version 2024-7-14
* @since API 3.0.0
*/
public interface IDhApiTerrainDataCache
{
/**
* Removes any data that's currently stored in this cache.
* This cane be done to free up memory or invalidate
* the cache so fresh data can be pulled in.
*/
void clear();
}
@@ -29,8 +29,6 @@ import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint;
/**
* Used to interface with Distant Horizons' terrain data.
*
* @see IDhApiTerrainDataCache
*
* @author James Seibel
* @version 2023-6-22
* @since API 1.0.0
@@ -42,50 +40,29 @@ public interface IDhApiTerrainDataRepo
// getters //
//=========//
/** @see IDhApiTerrainDataRepo#getSingleDataPointAtBlockPos(IDhApiLevelWrapper, int, int, int, IDhApiTerrainDataCache) */
default DhApiResult<DhApiTerrainDataPoint> getSingleDataPointAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ) { return this.getSingleDataPointAtBlockPos(levelWrapper, blockPosX, blockPosY, blockPosZ, null); }
/**
* Returns the terrain datapoint at the given block position, at/or containing the given Y position.
* @since API 3.0.0
*/
DhApiResult<DhApiTerrainDataPoint> getSingleDataPointAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ, IDhApiTerrainDataCache dataCache);
/** Returns the terrain datapoint at the given block position, at/or containing the given Y position. */
DhApiResult<DhApiTerrainDataPoint> getSingleDataPointAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ);
/** 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);
/** @see IDhApiTerrainDataRepo#getColumnDataAtBlockPos(IDhApiLevelWrapper, int, int, IDhApiTerrainDataCache) */
default DhApiResult<DhApiTerrainDataPoint[]> getColumnDataAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosZ) { return this.getColumnDataAtBlockPos(levelWrapper, blockPosX, blockPosZ, null); }
/**
* Returns every datapoint in the column located at the given block X and Z position top to bottom.
* @since API 3.0.0
*/
DhApiResult<DhApiTerrainDataPoint[]> getColumnDataAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosZ, IDhApiTerrainDataCache dataCache);
/** @see IDhApiTerrainDataRepo#getAllTerrainDataAtChunkPos(IDhApiLevelWrapper, int, int, IDhApiTerrainDataCache) */
default DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtChunkPos(IDhApiLevelWrapper levelWrapper, int chunkPosX, int chunkPosZ) { return this.getAllTerrainDataAtChunkPos(levelWrapper, chunkPosX, chunkPosZ, null); }
/**
* 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>
*
* @since API 3.0.0
*/
DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtChunkPos(IDhApiLevelWrapper levelWrapper, int chunkPosX, int chunkPosZ, IDhApiTerrainDataCache dataCache);
DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtChunkPos(IDhApiLevelWrapper levelWrapper, int chunkPosX, int chunkPosZ);
/** @see IDhApiTerrainDataRepo#getAllTerrainDataAtRegionPos(IDhApiLevelWrapper, int, int, IDhApiTerrainDataCache) */
default DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtRegionPos(IDhApiLevelWrapper levelWrapper, int regionPosX, int regionPosZ) { return this.getAllTerrainDataAtRegionPos(levelWrapper, regionPosX, regionPosZ, null); }
/**
* Returns every datapoint in the given region'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 region's position. <br>
* The column data is ordered from top to bottom. Note: each column may have a different number of values. <br>
*
* @since API 3.0.0
*/
DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtRegionPos(IDhApiLevelWrapper levelWrapper, int regionPosX, int regionPosZ, IDhApiTerrainDataCache dataCache);
DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtRegionPos(IDhApiLevelWrapper levelWrapper, int regionPosX, int regionPosZ);
/** @see IDhApiTerrainDataRepo#getAllTerrainDataAtDetailLevelAndPos(IDhApiLevelWrapper, byte, int, int, IDhApiTerrainDataCache) */
default DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtRegionPos(IDhApiLevelWrapper levelWrapper, byte detailLevel, int posX, int posZ) { return this.getAllTerrainDataAtDetailLevelAndPos(levelWrapper, detailLevel, posX, posZ, null); }
/**
* 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).
@@ -94,42 +71,20 @@ public interface IDhApiTerrainDataRepo
* 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.
*
* @since API 3.0.0
*/
DhApiResult<DhApiTerrainDataPoint[][][]> getAllTerrainDataAtDetailLevelAndPos(IDhApiLevelWrapper levelWrapper, byte detailLevel, int posX, int posZ, IDhApiTerrainDataCache dataCache);
/** @see IDhApiTerrainDataRepo#raycast(IDhApiLevelWrapper, double, double, double, float, float, float, int, IDhApiTerrainDataCache) */
default DhApiResult<DhApiRaycastResult> raycast(
IDhApiLevelWrapper levelWrapper,
double rayOriginX, double rayOriginY, double rayOriginZ,
float rayDirectionX, float rayDirectionY, float rayDirectionZ,
int maxRayBlockLength)
{
return this.raycast(
levelWrapper,
rayOriginX, rayOriginY, rayOriginZ,
rayDirectionX, rayDirectionY, rayDirectionZ,
maxRayBlockLength,
null);
}
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.
*
* @since API 3.0.0
*/
DhApiResult<DhApiRaycastResult> raycast(
IDhApiLevelWrapper levelWrapper,
double rayOriginX, double rayOriginY, double rayOriginZ,
float rayDirectionX, float rayDirectionY, float rayDirectionZ,
int maxRayBlockLength,
IDhApiTerrainDataCache dataCache);
int maxRayBlockLength);
@@ -143,27 +98,15 @@ public interface IDhApiTerrainDataRepo
* 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>
* - This method may not update the LOD data immediately. Any other chunks that have
* been queued to update will be handled first.
* 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.
*
* @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).
*/
DhApiResult<Void> overwriteChunkDataAsync(IDhApiLevelWrapper levelWrapper, Object[] chunkObjectArray) throws ClassCastException;
//=========//
// helpers //
//=========//
/**
* @return a {@link IDhApiTerrainDataCache} backed by {@link java.lang.ref.SoftReference}'s.
* @since API 3.0.0
*/
IDhApiTerrainDataCache getSoftCache();
public DhApiResult<Void> overwriteChunkDataAsync(IDhApiLevelWrapper levelWrapper, Object[] chunkObjectArray) throws ClassCastException;
}
@@ -31,7 +31,7 @@ import java.io.IOException;
*
* @author James Seibel
* @version 2023-12-16
* @since API 2.0.0
* @since API 1.1.0
*/
public interface IDhApiWrapperFactory
{
@@ -50,7 +50,7 @@ public interface IDhApiWrapperFactory
* @throws ClassCastException if any of the given parameters is of the wrong type.
* If thrown the error message will contain the list of expected object types in order.
*
* @since API 2.0.0
* @since API 1.1.0
*/
IDhApiBiomeWrapper getBiomeWrapper(Object[] objectArray, IDhApiLevelWrapper levelWrapper) throws ClassCastException;
@@ -67,46 +67,23 @@ public interface IDhApiWrapperFactory
* @throws ClassCastException if any of the given parameters is of the wrong type.
* If thrown the error message will contain the list of expected object types in order.
*
* @since API 2.0.0
* @since API 1.1.0
*/
IDhApiBlockStateWrapper getBlockStateWrapper(Object[] objectArray, IDhApiLevelWrapper levelWrapper) throws ClassCastException;
/**
* Returns the {@link IDhApiBlockStateWrapper} representing air.
* @since API 2.0.0
* @since API 1.1.0
*/
IDhApiBlockStateWrapper getAirBlockStateWrapper();
/**
* Constructs a {@link IDhApiBiomeWrapper} for use by other DhApi methods.
*
* @param resourceLocationString example: "minecraft:plains"
*
* @param levelWrapper Expects a {@link IDhApiLevelWrapper} returned by one of DH's {@link DhApi.Delayed#worldProxy} methods. <br>
* A custom implementation of {@link IDhApiLevelWrapper} will not be accepted.
*
* @throws IOException if the resourceLocationString wasn't able to be parsed or converted into a valid {@link IDhApiBiomeWrapper}
* @throws ClassCastException if the wrong levelWrapper type was given
*
* @since API 3.0.0
*/
IDhApiBiomeWrapper getBiomeWrapper(String resourceLocationString, IDhApiLevelWrapper levelWrapper) throws IOException, ClassCastException;
/**
* Constructs a {@link IDhApiBlockStateWrapper} for use by other DhApi methods.
* This returns the default blockstate for the given resource location.
*
* @param resourceLocationString examples: "minecraft:bedrock", "minecraft:stone", "minecraft:grass_block"
* @param levelWrapper Expects a {@link IDhApiBlockStateWrapper} returned by one of DH's {@link DhApi.Delayed#worldProxy} methods. <br>
* A custom implementation of {@link IDhApiBlockStateWrapper} will not be accepted.
*
* @throws IOException if the resourceLocationString wasn't able to be parsed or converted into a valid {@link IDhApiBlockStateWrapper}
* @throws ClassCastException if the wrong levelWrapper type was given
*
* @since API 3.0.0
*/
IDhApiBlockStateWrapper getDefaultBlockStateWrapper(String resourceLocationString, IDhApiLevelWrapper levelWrapper) throws IOException, ClassCastException;
///**
// * Specifically designed to be used with the API.
// *
// * @throws ClassCastException with instructions on expected objects if the object couldn't be cast
// */
//IChunkWrapper createChunkWrapper(Object[] objectArray) throws ClassCastException;
}
@@ -21,7 +21,7 @@ package com.seibel.distanthorizons.api.interfaces.override.rendering;
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
/**
* Used to determine if a LOD should be rendered or is outside the
@@ -29,7 +29,7 @@ import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
*
* @author James Seibel
* @version 2024-2-6
* @since API 2.0.0
* @since API 1.1.0
*/
public interface IDhApiCullingFrustum extends IDhApiOverrideable
{
@@ -41,7 +41,7 @@ public interface IDhApiCullingFrustum extends IDhApiOverrideable
* @param worldMaxBlockY the highest block position this level allows.
* @param worldViewProjection the projection matrix used in this render pass.
*/
void update(int worldMinBlockY, int worldMaxBlockY, DhApiMat4f worldViewProjection);
void update(int worldMinBlockY, int worldMaxBlockY, Mat4f worldViewProjection);
/**
* returns true if the LOD bounds intersect this frustum
@@ -24,7 +24,7 @@ import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
/**
* @author James Seibel
* @version 2024-1-24
* @since API 2.0.0
* @since API 1.1.0
*/
public interface IDhApiFramebuffer extends IDhApiOverrideable
{
@@ -1,80 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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.interfaces.override.rendering;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
/**
* @see IDhApiShaderProgram
*
* @author James Seibel
* @version 2024-7-11
* @since API 3.0.0
*/
public interface IDhApiGenericObjectShaderProgram extends IDhApiOverrideable
{
/**
* If this method is called that means this program has the highest priority as defined by {@link IDhApiOverrideable#getPriority()}
* and gets to decide if it wants to be used to render this frame or not. <br><br>
*
* If this method returns true then this program will be used for this frame. <br>
* If this returns false then the default DH {@link IDhApiGenericObjectShaderProgram} will be used instead.
*/
boolean overrideThisFrame();
/** @return the OpenGL ID for this shader program */
int getId();
/** Free any OpenGL objects owned by this program. */
void free();
/** Runs any necessary binding this program needs so rendering can be done. */
void bind(DhApiRenderParam renderEventParam);
/** Runs any necessary unbinding this program needs so rendering can be done by another program. */
void unbind();
/** Binds the given Vertex Buffer Object to this shader program for rendering. */
void bindVertexBuffer(int vbo);
/** sets up the necessary uniforms for rendering */
void fillIndirectUniformData(
DhApiRenderParam renderParameters,
DhApiRenderableBoxGroupShading shading, IDhApiRenderableBoxGroup boxGroup,
DhApiVec3d camPos);
/** sets up the necessary uniforms for rendering */
void fillSharedDirectUniformData(
DhApiRenderParam renderParameters,
DhApiRenderableBoxGroupShading shading, IDhApiRenderableBoxGroup boxGroup,
DhApiVec3d camPos);
void fillDirectUniformData(
DhApiRenderParam renderParameters,
IDhApiRenderableBoxGroup boxGroup, DhApiRenderableBox box,
DhApiVec3d camPos);
}
@@ -21,14 +21,13 @@ package com.seibel.distanthorizons.api.interfaces.override.rendering;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
import com.seibel.distanthorizons.coreapi.util.math.Vec3f;
/**
* @see IDhApiGenericObjectShaderProgram
*
* @author James Seibel
* @version 2024-1-24
* @since API 2.0.0
* @since API 1.1.0
*/
public interface IDhApiShaderProgram extends IDhApiOverrideable
{
@@ -58,7 +57,7 @@ public interface IDhApiShaderProgram extends IDhApiOverrideable
void fillUniformData(DhApiRenderParam renderParameters);
/** sets the vec3 that all DH verticies should be offset by when rendering */
void setModelOffsetPos(DhApiVec3f modelPos);
void setModelOffsetPos(Vec3f modelPos);
/** Binds the given Vertex Buffer Object to this shader program for rendering. */
void bindVertexBuffer(int vbo);
@@ -19,6 +19,10 @@
package com.seibel.distanthorizons.api.interfaces.override.rendering;
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
/**
* The culling frustum used during Distant Horizons' shadow pass
* if another mod has enabled Distant Horizons' shadow
@@ -31,7 +35,7 @@ package com.seibel.distanthorizons.api.interfaces.override.rendering;
*
* @author James Seibel
* @version 2024-2-10
* @since API 2.0.0
* @since API 1.1.0
*/
public interface IDhApiShadowCullingFrustum extends IDhApiCullingFrustum
{
@@ -22,8 +22,6 @@ package com.seibel.distanthorizons.api.interfaces.override.worldGenerator;
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
import com.seibel.distanthorizons.api.objects.data.DhApiChunk;
import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint;
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
import java.io.Closeable;
@@ -79,41 +77,13 @@ public abstract class AbstractDhApiChunkWorldGenerator implements Closeable, IDh
}, worldGeneratorThreadPool);
}
@Override
public final CompletableFuture<Void> generateApiChunks(
int chunkPosMinX,
int chunkPosMinZ,
byte granularity,
byte targetDataDetail,
EDhApiDistantGeneratorMode generatorMode,
ExecutorService worldGeneratorThreadPool,
Consumer<DhApiChunk> resultConsumer
)
{
return CompletableFuture.runAsync(() ->
{
// TODO what does this mean?
int genChunkWidth = BitShiftUtil.powerOfTwo(granularity - 4);
for (int chunkX = chunkPosMinX; chunkX < chunkPosMinX + genChunkWidth; chunkX++)
{
for (int chunkZ = chunkPosMinZ; chunkZ < chunkPosMinZ + genChunkWidth; chunkZ++)
{
DhApiChunk apiChunk = this.generateApiChunk(chunkX, chunkZ, generatorMode);
resultConsumer.accept(apiChunk);
}
}
}, worldGeneratorThreadPool);
}
/**
* This method is called to generate terrain over a given area
* from a thread defined by Distant Horizons. <br><br>
*
* @param chunkPosX the chunk X position in the level (not to be confused with the chunk's BlockPos in the level)
* @param chunkPosZ the chunk Z position in the level (not to be confused with the chunk's BlockPos in the level)
* @param generatorMode how far into the world gen pipeline this method should run. See {@link EDhApiDistantGeneratorMode} for additional documentation.
* @param generatorMode how far into the world gen pipeline this method run. See {@link EDhApiDistantGeneratorMode} for additional documentation.
*
* @return 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.
@@ -122,21 +92,4 @@ public abstract class AbstractDhApiChunkWorldGenerator implements Closeable, IDh
*/
public abstract Object[] generateChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode);
/**
* This method is called to generate terrain over a given area
* from a thread defined by Distant Horizons. <br><br>
*
* @param chunkPosX the chunk X position in the level (not to be confused with the chunk's BlockPos in the level)
* @param chunkPosZ the chunk Z position in the level (not to be confused with the chunk's BlockPos in the level)
* @param generatorMode how far into the world gen pipeline this method should run. See {@link EDhApiDistantGeneratorMode} for additional documentation.
*
* @return A {@link DhApiChunk} with the generated {@link DhApiTerrainDataPoint} including air blocks.
* Note: if air blocks aren't included with the proper lighting, lower detail levels will appear as black/unlit.
*
* @see IDhApiWorldGenerator#generateApiChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer)
*
* @since API 3.0.0
*/
public abstract DhApiChunk generateApiChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode);
}
@@ -90,29 +90,11 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
*/
default byte getMaxGenerationGranularity() { return (byte) (EDhApiDetailLevel.CHUNK.detailLevel + 2); }
/**
* Starting in API 3.0.0 DH now handles future queuing/management internally. <br><br>
*
* Previous description: <br>
* true if the generator is unable to accept new generation requests. <br>
*
* @since API 1.0.0
* @deprecated API 3.0.0
*/
@Deprecated
default boolean isBusy() { return false; }
/**
* Only used if {@link #getReturnType()} returns {@link EDhApiWorldGeneratorReturnType#API_CHUNKS}. <Br>
* If true DH will run additional validation on the {@link DhApiChunk}'s returned. <Br>
* This should be disabled during release but should be enabled during development to help spot issues with your data format.
*
* @see #getReturnType()
* @see DhApiChunk
* @see EDhApiWorldGeneratorReturnType#API_CHUNKS
* @since API 3.0.0
* @return true if the generator is unable to accept new generation requests.
* @since API 1.0.0
*/
default boolean runApiChunkValidation() { return true; }
boolean isBusy();
@@ -172,7 +154,6 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
*
* After the {@link DhApiChunk} has been generated, it should be passed into the
* resultConsumer's {@link Consumer#accept(Object)} method.
* Note: if air blocks aren't included in the with the {@link DhApiChunk} with proper lighting, lower detail levels will appear as black/unlit.
*
* @implNote the default implementation of this method throws an {@link UnsupportedOperationException},
* and must be overridden when {@link #getReturnType()} returns {@link EDhApiWorldGeneratorReturnType#API_CHUNKS}.
@@ -187,7 +168,7 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
*
* @return a future that should run on the worldGeneratorThreadPool and complete once the given generation task has completed.
*
* @since API 2.0.0
* @since API 1.1.0
*/
default CompletableFuture<Void> generateApiChunks(
int chunkPosMinX,
@@ -208,7 +189,7 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
* which means that {@link #generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer)}
* will be invoked whenever Distant Horizons wants to generate terrain with this world generator.
*
* @since API 2.0.0
* @since API 1.1.0
*/
default EDhApiWorldGeneratorReturnType getReturnType() { return EDhApiWorldGeneratorReturnType.VANILLA_CHUNKS; }
@@ -1,67 +0,0 @@
package com.seibel.distanthorizons.api.interfaces.render;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import java.util.List;
/**
* Handles creating
* {@link IDhApiRenderableBoxGroup} objects,
* which can be added via a {@link IDhApiCustomRenderRegister}.
*
* @see IDhApiCustomRenderRegister
* @see IDhApiRenderableBoxGroup
*
* @author James Seibel
* @version 2024-7-3
* @since API 3.0.0
*/
public interface IDhApiCustomRenderObjectFactory
{
/**
* Creates a {@link IDhApiRenderableBoxGroup} from for the given {@link DhApiRenderableBox}
* where the box is positioned relative to the level's origin.
*
* @param resourceLocation A colon separated Resource Location string, similar to vanilla Minecraft, for example: "DistantHorizons:Clouds"
*
* @see DhApiRenderableBox
* @see IDhApiRenderableBoxGroup#getResourceLocationNamespace()
* @see IDhApiRenderableBoxGroup#getResourceLocationPath()
*
* @throws IllegalArgumentException if <code>resourceLocation</code> is null, isn't separated by a colon, or has multiple colons.
*/
IDhApiRenderableBoxGroup createForSingleBox(String resourceLocation, DhApiRenderableBox cube) throws IllegalArgumentException;
/**
* Creates a {@link IDhApiRenderableBoxGroup} from the given list of {@link DhApiRenderableBox} where each
* one is positioned relative to given <code>originBlockPos</code>, which in turn is relative to the level's origin.
*
* @param resourceLocation A colon separated Resource Location string, similar to vanilla Minecraft, for example: "DistantHorizons:Clouds"
* @param originBlockPos The starting position for this {@link IDhApiRenderableBoxGroup}, can be changed during runtime.
*
*
* @see DhApiRenderableBox
* @see IDhApiRenderableBoxGroup#getResourceLocationNamespace()
* @see IDhApiRenderableBoxGroup#getResourceLocationPath()
*
* @throws IllegalArgumentException if <code>resourceLocation</code> is null, isn't separated by a colon, or has multiple colons.
*/
IDhApiRenderableBoxGroup createRelativePositionedGroup(String resourceLocation, DhApiVec3d originBlockPos, List<DhApiRenderableBox> cubeList);
/**
* Creates a {@link IDhApiRenderableBoxGroup} from the given list of {@link DhApiRenderableBox} where each
* one is positioned relative to the level's origin.
*
* @param resourceLocation A colon separated Resource Location string, similar to vanilla Minecraft, for example: "DistantHorizons:Clouds"
*
* @see DhApiRenderableBox
* @see IDhApiRenderableBoxGroup#getResourceLocationNamespace()
* @see IDhApiRenderableBoxGroup#getResourceLocationPath()
*
* @throws IllegalArgumentException if <code>resourceLocation</code> is null, isn't separated by a colon, or has multiple colons.
*/
IDhApiRenderableBoxGroup createAbsolutePositionedGroup(String resourceLocation, List<DhApiRenderableBox> cubeList);
}
@@ -1,30 +0,0 @@
package com.seibel.distanthorizons.api.interfaces.render;
import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiWorldProxy;
/**
* Handles adding and removing
* {@link IDhApiRenderableBoxGroup} objects,
* from DH's renderer. <br><br>
*
* Can be accessed in
* {@link DhApi.Delayed#worldProxy} -> {@link IDhApiLevelWrapper}.
*
* @see IDhApiCustomRenderObjectFactory
* @see IDhApiRenderableBoxGroup
* @see IDhApiWorldProxy
* @see IDhApiLevelWrapper
*
* @author James Seibel
* @version 2024-7-3
* @since API 3.0.0
*/
public interface IDhApiCustomRenderRegister
{
void add(IDhApiRenderableBoxGroup cubeGroup) throws IllegalArgumentException;
IDhApiRenderableBoxGroup remove(long id);
}
@@ -26,7 +26,7 @@ import com.seibel.distanthorizons.api.objects.DhApiResult;
* Used to interact with Distant Horizons' rendering system.
*
* @author James Seibel
* @version 2024-7-27
* @version 2023-10-13
* @since API 1.0.0
*/
public interface IDhApiRenderProxy
@@ -39,8 +39,10 @@ public interface IDhApiRenderProxy
* If this is called on a dedicated server it won't do anything and will return {@link DhApiResult#success} = false <Br><Br>
*
* Background: <Br>
* When rendering Distant Horizons bakes each block's color into the geometry that's rendered. <Br>
* This improves rendering speed and VRAM size, but prevents dynamically changing LOD colors. <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.
*/
DhApiResult<Boolean> clearRenderDataCache();
@@ -1,98 +0,0 @@
package com.seibel.distanthorizons.api.interfaces.render;
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
import java.util.List;
import java.util.function.Consumer;
/**
* A list of {@link DhApiRenderableBox}'s that
* can be rendered to DH's terrain pass.
*
* @see DhApiRenderableBox
*
* @author James Seibel
* @version 2024-6-30
* @since API 3.0.0
*/
public interface IDhApiRenderableBoxGroup extends List<DhApiRenderableBox>
{
/**
* A unique numerical ID used by DH during rendering.
* This can also be used to bind/unbind specific {@link IDhApiRenderableBoxGroup}'s from the renderer.
* @return the ID for this specific group
*/
long getId();
/**
* Used to determine which mods have added what to the DH renderer.
* This can be used both by the F3 pie chart so you as a mod developer can profile your code
* or by shader developers who want to render your objects differently. <br><br>
*
* Should be used the same as a vanilla Minecraft ResourceLocation.
* For example if your mod named "Heavy Thunder" adds additional clouds named "Storm Front",
* your Resource Location would be something like "HeavyThunder:StormFront"
* and this method would return "HeavyThunder".
*/
String getResourceLocationNamespace();
/**
* Used to determine what type of object mods have added what to the DH renderer.
* This can be used both by the F3 pie chart so you as a mod developer can profile your code
* or by shader developers who want to render your objects differently. <br><br>
*
* Should be used the same as a vanilla Minecraft ResourceLocation.
* For example if your mod named "Heavy Thunder" adds additional clouds named "Storm Front",
* your Resource Location would be something like "HeavyThunder:StormFront"
* and this method would return "StormFront".
*/
String getResourceLocationPath();
/** Sets whether this group should render or not. */
void setActive(boolean active);
/** @return if active this group will render. */
boolean isActive();
/** Sets whether this group should render with Screen Space Ambient Occlusioning. */
void setSsaoEnabled(boolean ssaoEnabled);
/** @return if active this group will render with Screen Space Ambient Occlusioning. */
boolean isSsaoEnabled();
/** Sets where this group will render in the level. */
void setOriginBlockPos(DhApiVec3d pos);
/** @return the block position in the level that all {@see DhApiRenderableBox} will render relative to. */
DhApiVec3d getOriginBlockPos();
/**
* Called right before this group is rendered. <br>
* This is a good place to change the origin or notify of any box changes.
*/
void setPreRenderFunc(Consumer<DhApiRenderParam> renderEventParam);
void setPostRenderFunc(Consumer<DhApiRenderParam> renderEventParam); // TODO name?
/**
* If a cube's color, position, or other property is changed this method
* must be called for those changes to render. <br><br>
*
* Note: changing the group's position via {@link #setOriginBlockPos} doesn't
* require calling this method.
*/
void triggerBoxChange();
/** Only accepts values between 0 and 15 */
void setSkyLight(int skyLight);
int getSkyLight();
/** Only accepts values between 0 and 15 */
void setBlockLight(int blockLight);
int getBlockLight();
void setShading(DhApiRenderableBoxGroupShading shading);
DhApiRenderableBoxGroupShading getShading();
}
@@ -1,18 +0,0 @@
package com.seibel.distanthorizons.api.interfaces.util;
/**
* Used for objects that need deep clones. <br>
* Replacement for {@link Cloneable}.
*
* @see Cloneable
*
* @author James Seibel
* @version 2024-7-12
* @since API 3.0.0
*/
public interface IDhApiCopyable
{
/** Returns a deep clone of all parameters whenever possible. */
IDhApiCopyable copy();
}
@@ -21,14 +21,13 @@ package com.seibel.distanthorizons.api.interfaces.world;
import com.seibel.distanthorizons.api.interfaces.IDhApiUnsafeWrapper;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
/**
* Can be either a Server or Client level.<br>
* A level is equivalent to a dimension in vanilla Minecraft.
*
* @author James Seibel
* @version 2024-7-28
* @version 2022-7-14
* @since API 1.0.0
*/
public interface IDhApiLevelWrapper extends IDhApiUnsafeWrapper
@@ -41,19 +40,8 @@ public interface IDhApiLevelWrapper extends IDhApiUnsafeWrapper
boolean hasSkyLight();
/**
* Deprecated, use {@link IDhApiLevelWrapper#getMaxHeight} instead. <br>
* Returns the max block height of the level.
*
* @see IDhApiLevelWrapper#getMaxHeight
*/
@Deprecated
default int getHeight() { return this.getMaxHeight(); }
/**
* Returns the max block height of the level
* @since API 3.0.0
*/
int getMaxHeight();
/** Returns the max block height of the level(?) */
int getHeight();
/**
* Returns the lowest possible block position for the level. <br>
@@ -61,12 +49,4 @@ public interface IDhApiLevelWrapper extends IDhApiUnsafeWrapper
*/
default int getMinHeight() { return 0; }
/**
* Will return null if called on the server,
* or if called before the renderer has been set up.
*
* @since API 3.0.0
*/
IDhApiCustomRenderRegister getRenderRegister();
}
@@ -26,20 +26,17 @@ 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. <br><br>
* did to the OpenGL state, so the state should be back to Minecraft's defaults.
*
* Note: as of API v 3.0.0 no {@link DhApiRenderParam} is included in this event
* because the specific parameters may change
* depending on whether deferred rendering is enabled or not.
*
* @author James Seibel
* @version 2024-7-14
* @version 2024-1-31
* @see DhApiRenderParam
* @since API 1.0.0
*/
public abstract class DhApiAfterRenderEvent implements IDhApiEvent<Void>
public abstract class DhApiAfterRenderEvent implements IDhApiEvent<DhApiRenderParam>
{
/** Fired after Distant Horizons finishes rendering fake chunks. */
public abstract void afterRender(DhApiEventParam<Void> event);
public abstract void afterRender(DhApiEventParam<DhApiRenderParam> event);
//=========================//
@@ -47,6 +44,6 @@ public abstract class DhApiAfterRenderEvent implements IDhApiEvent<Void>
//=========================//
@Override
public final void fireEvent(DhApiEventParam<Void> event) { this.afterRender(event); }
public final void fireEvent(DhApiEventParam<DhApiRenderParam> event) { this.afterRender(event); }
}
@@ -31,7 +31,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2024-1-31
* @since API 2.0.0
* @since API 1.1.0
*/
public abstract class DhApiBeforeApplyShaderRenderEvent implements IDhApiCancelableEvent<DhApiRenderParam>
{
@@ -20,10 +20,9 @@
package com.seibel.distanthorizons.api.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.coreapi.util.math.Vec3f;
/**
* Called before Distant Horizons starts rendering a buffer. <br>
@@ -31,7 +30,7 @@ import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
*
* @author James Seibel
* @version 2023-1-31
* @since API 2.0.0
* @since API 1.1.0
*
* @see DhApiBeforeRenderEvent
*/
@@ -53,29 +52,20 @@ public abstract class DhApiBeforeBufferRenderEvent implements IDhApiEvent<DhApiB
// parameter object //
//==================//
public static class EventParam extends DhApiRenderParam implements IDhApiEventParam
public static class EventParam extends DhApiRenderParam
{
/**
* Measured in blocks.
* Should be applied to the model view matrix to move the buffer into its proper place.
*/
public final DhApiVec3f modelPos;
public final Vec3f modelPos;
public EventParam(DhApiRenderParam parent, DhApiVec3f modelPos)
public EventParam(DhApiRenderParam parent, Vec3f modelPos)
{
super(parent);
this.modelPos = modelPos;
}
@Override
public EventParam copy()
{
return new EventParam(
this, this.modelPos.copy()
);
}
}
}
@@ -29,7 +29,7 @@ import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderProxy;
*
* @author James Seibel
* @version 2024-1-22
* @since API 2.0.0
* @since API 1.1.0
*/
public abstract class DhApiBeforeDeferredRenderEvent extends DhApiBeforeRenderEvent
{
@@ -1,97 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiCancelableEvent;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiCancelableEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
/**
* Called before Distant Horizons starts rendering a generic object. <br>
* Canceling this event will prevent the triggering {@link IDhApiRenderableBoxGroup} from rendering this frame.
*
* @author James Seibel
* @version 2024-7-11
* @since API 3.0.0
*/
public abstract class DhApiBeforeGenericObjectRenderEvent implements IDhApiCancelableEvent<DhApiBeforeGenericObjectRenderEvent.EventParam>
{
/** Fired before Distant Horizons renders a generic object. */
public abstract void beforeRender(DhApiCancelableEventParam<EventParam> event);
//=========================//
// internal DH API methods //
//=========================//
@Override
public final void fireEvent(DhApiCancelableEventParam<EventParam> input) { this.beforeRender(input); }
//==================//
// parameter object //
//==================//
public static class EventParam extends DhApiRenderParam implements IDhApiEventParam
{
public final long boxGroupId;
public final String resourceLocationNamespace;
public final String resourceLocationPath;
public EventParam(
DhApiRenderParam renderParam,
IDhApiRenderableBoxGroup boxGroup
)
{
super(renderParam);
this.boxGroupId = boxGroup.getId();
this.resourceLocationNamespace = boxGroup.getResourceLocationNamespace();
this.resourceLocationPath = boxGroup.getResourceLocationPath();
}
public EventParam(
DhApiRenderParam renderParam,
long boxGroupId, String resourceLocationNamespace, String resourceLocationPath
)
{
super(renderParam);
this.boxGroupId = boxGroupId;
this.resourceLocationNamespace = resourceLocationNamespace;
this.resourceLocationPath = resourceLocationPath;
}
@Override
public EventParam copy()
{
return new EventParam(
this,
this.boxGroupId, this.resourceLocationNamespace, this.resourceLocationPath
);
}
}
}
@@ -1,47 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
/**
* Called before Distant Horizons starts the cleanup process done after rendering generic objects. <br>
* This is called after all generic objects have finished rendering.
*
* @author James Seibel
* @version 2024-7-13
* @since API 3.0.0
*/
public abstract class DhApiBeforeGenericRenderCleanupEvent implements IDhApiEvent<DhApiRenderParam>
{
/** Fired before Distant Horizons starts the cleanup process once rendering has finished. */
public abstract void beforeCleanup(DhApiEventParam<DhApiRenderParam> event);
//=========================//
// internal DH API methods //
//=========================//
@Override
public final void fireEvent(DhApiEventParam<DhApiRenderParam> event) { this.beforeCleanup(event); }
}
@@ -1,50 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
/**
* Called before Distant Horizons has started setting up OpenGL objects for rendering generic objects. <br>
* If you want to modify already bound DH OpenGL objects try using {@link DhApiBeforeGenericObjectRenderEvent}.
*
* @author James Seibel
* @version 2024-7-12
* @since API 3.0.0
*
* @see DhApiBeforeGenericObjectRenderEvent
*/
public abstract class DhApiBeforeGenericRenderSetupEvent implements IDhApiEvent<DhApiRenderParam>
{
/** Fired before Distant Horizons has started setting up OpenGL objects for rendering generic objects. */
public abstract void beforeSetup(DhApiEventParam<DhApiRenderParam> input);
//=========================//
// internal DH API methods //
//=========================//
@Override
public final void fireEvent(DhApiEventParam<DhApiRenderParam> input) { this.beforeSetup(input); }
}
@@ -29,11 +29,11 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2024-1-31
* @since API 2.0.0
* @since API 1.1.0
*/
public abstract class DhApiBeforeRenderCleanupEvent implements IDhApiEvent<DhApiRenderParam>
{
/** Fired before Distant Horizons starts the cleanup process once rendering has finished. */
/** Fired before Distant Horizons renders LODs. */
public abstract void beforeCleanup(DhApiEventParam<DhApiRenderParam> event);
@@ -31,7 +31,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2023-1-31
* @since API 2.0.0
* @since API 1.1.0
*
* @see DhApiBeforeRenderEvent
*/
@@ -29,7 +29,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2024-1-31
* @since API 2.0.0
* @since API 1.1.0
*
* @see DhApiBeforeRenderPassEvent
*/
@@ -31,7 +31,7 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
*
* @author James Seibel
* @version 2024-1-31
* @since API 2.0.0
* @since API 1.1.0
*/
public abstract class DhApiBeforeTextureClearEvent implements IDhApiCancelableEvent<DhApiRenderParam>
{
@@ -22,7 +22,6 @@ package com.seibel.distanthorizons.api.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.interfaces.data.IDhApiTerrainDataRepo;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
/**
@@ -54,7 +53,7 @@ public abstract class DhApiChunkModifiedEvent implements IDhApiEvent<DhApiChunkM
// parameter object //
//==================//
public static class EventParam implements IDhApiEventParam
public static class EventParam
{
/** The saved level. */
public final IDhApiLevelWrapper levelWrapper;
@@ -72,15 +71,6 @@ public abstract class DhApiChunkModifiedEvent implements IDhApiEvent<DhApiChunkM
this.chunkZ = chunkZ;
}
@Override
public EventParam copy()
{
return new EventParam(
this.levelWrapper,
this.chunkX, this.chunkZ
);
}
}
}
@@ -21,7 +21,6 @@ package com.seibel.distanthorizons.api.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
/**
@@ -50,16 +49,13 @@ public abstract class DhApiLevelLoadEvent implements IDhApiEvent<DhApiLevelLoadE
// parameter object //
//==================//
public static class EventParam implements IDhApiEventParam
public static class EventParam
{
/** The newly loaded level. */
public final IDhApiLevelWrapper levelWrapper;
public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
@Override
public EventParam copy() { return new EventParam(this.levelWrapper); }
}
}
@@ -19,9 +19,9 @@
package com.seibel.distanthorizons.api.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
/**
@@ -49,16 +49,13 @@ public abstract class DhApiLevelUnloadEvent implements IDhApiEvent<DhApiLevelUnl
// parameter object //
//==================//
public static class EventParam implements IDhApiEventParam
public static class EventParam
{
/** The recently unloaded level. */
public final IDhApiLevelWrapper levelWrapper;
public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
@Override
public EventParam copy() { return new EventParam(this.levelWrapper); }
}
}
@@ -20,20 +20,19 @@
package com.seibel.distanthorizons.api.methods.events.abstractEvents;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
/**
* Called whenever Distant Horizons (re)creates
* the color and depth textures it renders to. <br>
* Called before Distant Horizons starts rendering a buffer. <br>
* This event cannot be cancelled, use {@link DhApiBeforeRenderEvent} if you want to cancel rendering.
*
* @author James Seibel
* @version 2024-3-2
* @since API 2.0.0
* @version 2023-1-23
* @since API 1.1.0
*/
public abstract class DhApiColorDepthTextureCreatedEvent implements IDhApiEvent<DhApiColorDepthTextureCreatedEvent.EventParam>
public abstract class DhApiScreenResizeEvent implements IDhApiEvent<DhApiScreenResizeEvent.EventParam>
{
/** Fired before Distant Horizons creates. */
/** Fired immediately before Distant Horizons renders any transparent buffers. */
public abstract void onResize(DhApiEventParam<EventParam> event);
@@ -49,7 +48,7 @@ public abstract class DhApiColorDepthTextureCreatedEvent implements IDhApiEvent<
// parameter object //
//==================//
public static class EventParam implements IDhApiEventParam
public static class EventParam
{
/** Measured in pixels */
public final int previousWidth;
@@ -73,16 +72,6 @@ public abstract class DhApiColorDepthTextureCreatedEvent implements IDhApiEvent<
this.newHeight = newHeight;
}
@Override
public EventParam copy()
{
return new EventParam(
this.previousWidth, this.previousHeight,
this.newWidth, this.newHeight
);
}
}
}
@@ -1,13 +0,0 @@
package com.seibel.distanthorizons.api.methods.events.interfaces;
import com.seibel.distanthorizons.api.interfaces.util.IDhApiCopyable;
/**
* @author James Seibel
* @version 2024-7-12
* @since API 3.0.0
*/
public interface IDhApiEventParam extends IDhApiCopyable
{
}
@@ -20,8 +20,7 @@
package com.seibel.distanthorizons.api.methods.events.sharedParameterObjects;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
/**
* Contains information relevant to Distant Horizons and Minecraft rendering.
@@ -30,7 +29,7 @@ import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
* @version 2024-1-31
* @since API 1.0.0
*/
public class DhApiRenderParam implements IDhApiEventParam
public class DhApiRenderParam
{
/** Indicates what render pass DH is currently rendering */
public final EDhApiRenderPass renderPass;
@@ -50,15 +49,18 @@ public class DhApiRenderParam implements IDhApiEventParam
public final float farClipPlane;
/** The projection matrix Minecraft is using to render this frame. */
public final DhApiMat4f mcProjectionMatrix;
public final Mat4f mcProjectionMatrix;
/** The model view matrix Minecraft is using to render this frame. */
public final DhApiMat4f mcModelViewMatrix;
public final Mat4f mcModelViewMatrix;
/** The projection matrix Distant Horizons is using to render this frame. */
public final DhApiMat4f dhProjectionMatrix;
public final Mat4f dhProjectionMatrix;
/** The model view matrix Distant Horizons is using to render this frame. */
public final DhApiMat4f dhModelViewMatrix;
public final Mat4f dhModelViewMatrix;
public final int lightmapBindingIndex = 0;
// TODO why is this here? wouldn't it make more sense to have this built into the vertex buffer data?
public final int worldYOffset;
@@ -67,24 +69,24 @@ public class DhApiRenderParam implements IDhApiEventParam
// constructors //
//==============//
public DhApiRenderParam(DhApiRenderParam parent)
{
this(
parent.renderPass,
parent.partialTicks,
parent.nearClipPlane, parent.farClipPlane,
parent.mcProjectionMatrix.copy(), parent.mcModelViewMatrix.copy(),
parent.dhProjectionMatrix.copy(), parent.dhModelViewMatrix.copy(),
parent.worldYOffset
);
parent.renderPass,
parent.partialTicks,
parent.nearClipPlane, parent.farClipPlane,
parent.mcProjectionMatrix, parent.mcModelViewMatrix,
parent.dhProjectionMatrix, parent.dhModelViewMatrix,
parent.worldYOffset
);
}
public DhApiRenderParam(
EDhApiRenderPass renderPass,
float newPartialTicks,
float nearClipPlane, float farClipPlane,
DhApiMat4f newMcProjectionMatrix, DhApiMat4f newMcModelViewMatrix,
DhApiMat4f newDhProjectionMatrix, DhApiMat4f newDhModelViewMatrix,
Mat4f newMcProjectionMatrix, Mat4f newMcModelViewMatrix,
Mat4f newDhProjectionMatrix, Mat4f newDhModelViewMatrix,
int worldYOffset
)
{
@@ -105,16 +107,4 @@ public class DhApiRenderParam implements IDhApiEventParam
}
//================//
// base overrides //
//================//
@Override
public DhApiRenderParam copy()
{
return new DhApiRenderParam(this);
}
}
@@ -21,18 +21,16 @@ package com.seibel.distanthorizons.api.objects.data;
import com.seibel.distanthorizons.api.interfaces.factories.IDhApiWrapperFactory;
import com.seibel.distanthorizons.api.interfaces.override.worldGenerator.IDhApiWorldGenerator;
import org.apache.logging.log4j.LogManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Contains a list of {@link DhApiTerrainDataPoint} representing the blocks in a Minecraft chunk.
*
* @author Builderb0y, James Seibel
* @version 2024-7-21
* @since API 2.0.0
* @version 2023-12-21
* @since API 1.1.0
*
* @see IDhApiWrapperFactory
* @see DhApiTerrainDataPoint
@@ -43,8 +41,8 @@ public class DhApiChunk
public final int chunkPosX;
public final int chunkPosZ;
public final int bottomYBlockPos;
public final int topYBlockPos;
public final int bottomYBlockPos;
private final List<List<DhApiTerrainDataPoint>> dataPoints;
@@ -54,32 +52,12 @@ public class DhApiChunk
// constructors //
//==============//
/**
* Deprecated due to the topYBlockPos and bottomYBlockPos variables being put in the wrong order.
* They should have been in bottom -> top order.
*
* @see DhApiChunk#create(int, int, int, int)
*/
@Deprecated
public DhApiChunk(int chunkPosX, int chunkPosZ, int topYBlockPos, int bottomYBlockPos)
{ this(chunkPosX, chunkPosZ, bottomYBlockPos, topYBlockPos, false); }
/**
* @since API 3.0.0
*/
public static DhApiChunk create(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos)
{ return new DhApiChunk(chunkPosX, chunkPosZ, bottomYBlockPos, topYBlockPos, false); }
/**
* Only visible to internal DH methods
* @param ignoredParameter is only present to differentiate the two constructors and isn't actually used
*/
private DhApiChunk(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos, boolean ignoredParameter)
{
this.chunkPosX = chunkPosX;
this.chunkPosZ = chunkPosZ;
this.bottomYBlockPos = bottomYBlockPos;
this.topYBlockPos = topYBlockPos;
this.bottomYBlockPos = bottomYBlockPos;
// populate the array to prevent null pointers
this.dataPoints = new ArrayList<>(16 * 16); // 256
@@ -116,34 +94,27 @@ public class DhApiChunk
*/
public void setDataPoints(int relX, int relZ, List<DhApiTerrainDataPoint> dataPoints) throws IndexOutOfBoundsException, IllegalArgumentException
{
//==================//
// basic validation //
//==================//
// heavier validation is done in the world generator if requested
int internalArrayIndex = (relZ << 4) | relX;
throwIfRelativePosOutOfBounds(relX, relZ);
if (dataPoints == null)
// validate the incoming datapoints
if (dataPoints != null)
{
// we don't allow null columns
throw new IllegalArgumentException("Null columns aren't allowed. If you want to remove all data from a column please clear the list or pass in an empty list.");
for (int i = 0; i < dataPoints.size(); i++) // standard for-loop used instead of an enhanced for-loop to slightly reduce GC overhead due to iterator allocation
{
DhApiTerrainDataPoint dataPoint = dataPoints.get(i);
if (dataPoint == null)
{
throw new IllegalArgumentException("Null DhApiTerrainDataPoints are not allowed. If you want to represent empty terrain, please use AIR.");
}
if (dataPoint.detailLevel != 0)
{
throw new IllegalArgumentException("DhApiTerrainDataPoints has the wrong detail level ["+dataPoint.detailLevel+"], all data points must be block sized; IE their detail level must be [0].");
}
}
}
//================//
// set datapoints //
//================//
List<DhApiTerrainDataPoint> column = this.dataPoints.get(internalArrayIndex);
if (column == null)
{
column = new ArrayList<>();
this.dataPoints.set(internalArrayIndex, column);
}
column.addAll(dataPoints);
this.dataPoints.set((relZ << 4) | relX, dataPoints);
}
@@ -20,6 +20,7 @@
package com.seibel.distanthorizons.api.objects.data;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
import com.seibel.distanthorizons.coreapi.util.math.Vec3i;
/**
* Holds a single datapoint of terrain data
@@ -46,7 +47,7 @@ public class DhApiRaycastResult
public DhApiRaycastResult(DhApiTerrainDataPoint dataPoint, DhApiVec3i blockPos)
public DhApiRaycastResult(DhApiTerrainDataPoint dataPoint, Vec3i blockPos)
{
this.dataPoint = dataPoint;
this.pos = blockPos;
@@ -19,17 +19,14 @@
package com.seibel.distanthorizons.api.objects.data;
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBiomeWrapper;
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
import java.util.ArrayList;
/**
* Holds a single datapoint of terrain data.
*
* @author James Seibel
* @version 2024-7-20
* @version 2022-11-13
* @since API 1.0.0
*/
public class DhApiTerrainDataPoint
@@ -40,79 +37,25 @@ public class DhApiTerrainDataPoint
* 2 = 4x4 blocks <br>
* 4 = chunk (16x16 blocks) <br>
* 9 = region (512x512 blocks) <br>
*
* @see EDhApiDetailLevel
*/
public final byte detailLevel;
public final int blockLightLevel;
public final int skyLightLevel;
public final int bottomYBlockPos;
public final int lightLevel;
public final int topYBlockPos;
public final int bottomYBlockPos;
public final IDhApiBlockStateWrapper blockStateWrapper;
public final IDhApiBiomeWrapper biomeWrapper;
//==============//
// constructors //
//==============//
/**
* Deprecated due to the topYBlockPos and bottomYBlockPos variables being put in the wrong order.
* They should have been in bottom -> top order.
*
* @see DhApiTerrainDataPoint#create(byte, int, int, int, int, IDhApiBlockStateWrapper, IDhApiBiomeWrapper)
*/
@Deprecated
public DhApiTerrainDataPoint(
byte detailLevel,
int blockLightLevel, int skyLightLevel,
int topYBlockPos, int bottomYBlockPos,
IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper)
{
this(detailLevel, blockLightLevel, skyLightLevel,
bottomYBlockPos, topYBlockPos,
blockStateWrapper, biomeWrapper,
false);
}
/**
* @since API 3.0.0
*/
public static DhApiTerrainDataPoint create(
byte detailLevel,
int blockLightLevel, int skyLightLevel,
int bottomYBlockPos, int topYBlockPos,
IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper
)
{
return new DhApiTerrainDataPoint(
detailLevel, blockLightLevel, skyLightLevel,
bottomYBlockPos, topYBlockPos,
blockStateWrapper, biomeWrapper,
false);
}
/**
* Only visible to internal DH methods
* @param ignoredParameter is only present to differentiate the two constructors and isn't actually used
*/
private DhApiTerrainDataPoint(
byte detailLevel,
int blockLightLevel, int skyLightLevel,
int bottomYBlockPos, int topYBlockPos,
IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper,
boolean ignoredParameter
)
public DhApiTerrainDataPoint(byte detailLevel, int lightLevel, int topYBlockPos, int bottomYBlockPos, IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper)
{
this.detailLevel = detailLevel;
this.blockLightLevel = blockLightLevel;
this.skyLightLevel = skyLightLevel;
this.bottomYBlockPos = bottomYBlockPos;
this.lightLevel = lightLevel;
this.topYBlockPos = topYBlockPos;
this.bottomYBlockPos = bottomYBlockPos;
this.blockStateWrapper = blockStateWrapper;
this.biomeWrapper = biomeWrapper;
@@ -1,94 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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.objects.math;
/**
* Often used to store block positions or any other
* position in 3D space.
*
* @author James Seibel
* @version 2024-7-9
* @since API 3.0.0
*/
public class DhApiVec3d
{
public double x;
public double y;
public double z;
/** creates a Vec3 at (0,0,0) */
public DhApiVec3d()
{
this.x = 0;
this.y = 0;
this.z = 0;
}
public DhApiVec3d(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
else if (obj != null && this.getClass() == obj.getClass())
{
DhApiVec3d Vec3d = (DhApiVec3d) obj;
if (Double.compare(Vec3d.x, this.x) != 0)
{
return false;
}
else if (Double.compare(Vec3d.y, this.y) != 0)
{
return false;
}
else
{
return Double.compare(Vec3d.z, this.z) == 0;
}
}
else
{
return false;
}
}
@Override
public int hashCode()
{
long i = Double.doubleToLongBits(this.x);
i = 31 * i + Double.doubleToLongBits(this.y);
i = 31 * i + Double.doubleToLongBits(this.z);
return Long.hashCode(i);
}
@Override
public String toString() { return "[" + this.x + ", " + this.y + ", " + this.z + "]"; }
}
@@ -1,98 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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.objects.math;
import com.seibel.distanthorizons.api.interfaces.util.IDhApiCopyable;
/**
* Often used to store block positions or any other
* position in 3D space.
*
* @author James Seibel
* @version 2024-6-3
* @since API 2.2.0
*/
public class DhApiVec3f implements IDhApiCopyable
{
public float x;
public float y;
public float z;
/** creates a Vec3 at (0,0,0) */
public DhApiVec3f()
{
this.x = 0;
this.y = 0;
this.z = 0;
}
public DhApiVec3f(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
else if (obj != null && this.getClass() == obj.getClass())
{
DhApiVec3f Vec3f = (DhApiVec3f) obj;
if (Float.compare(Vec3f.x, this.x) != 0)
{
return false;
}
else if (Float.compare(Vec3f.y, this.y) != 0)
{
return false;
}
else
{
return Float.compare(Vec3f.z, this.z) == 0;
}
}
else
{
return false;
}
}
@Override
public int hashCode()
{
int i = Float.floatToIntBits(this.x);
i = 31 * i + Float.floatToIntBits(this.y);
return 31 * i + Float.floatToIntBits(this.z);
}
@Override
public String toString() { return "[" + this.x + ", " + this.y + ", " + this.z + "]"; }
@Override
public DhApiVec3f copy() { return new DhApiVec3f(this.x, this.y, this.z); }
}
@@ -1,52 +0,0 @@
package com.seibel.distanthorizons.api.objects.render;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import java.awt.*;
/**
* @see IDhApiRenderableBoxGroup
*
* @author James Seibel
* @version 2024-6-30
* @since API 3.0.0
*/
public class DhApiRenderableBox
{
/** the position closest to (-inf,-inf) */
public DhApiVec3d minPos;
/** the position closest to (+inf,+inf) */
public DhApiVec3d maxPos;
public Color color;
public byte material;
//==============//
// constructors //
//==============//
public DhApiRenderableBox(DhApiVec3d minPos, float width, Color color, EDhApiBlockMaterial material)
{
this(minPos, new DhApiVec3d(
minPos.x + width,
minPos.y + width,
minPos.z + width
), color, material);
}
public DhApiRenderableBox(DhApiVec3d minPos, DhApiVec3d maxPos, Color color, EDhApiBlockMaterial material)
{
this.minPos = minPos;
this.maxPos = maxPos;
this.color = color;
this.material = material.index;
}
}
@@ -1,93 +0,0 @@
package com.seibel.distanthorizons.api.objects.render;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import java.awt.*;
/**
* @see IDhApiRenderableBoxGroup
*
* Shading values are multiplied against the color for each direction,
* for example: <br>
* A shading value of 1.0 indicates the color is unchanged. <br>
* A shading value of 0.0 changes the color to black. <br>
*
* @author James Seibel
* @version 2024-7-7
* @since API 3.0.0
*/
public class DhApiRenderableBoxGroupShading
{
/** negative X */
public float north = 1.0f;
/** positive X */
public float south = 1.0f;
/** positive X */
public float east = 1.0f;
/** negative X */
public float west = 1.0f;
/** positive Y */
public float top = 1.0f;
/** negative Y */
public float bottom = 1.0f;
//==============//
// constructors //
//==============//
public static DhApiRenderableBoxGroupShading getDefaultShaded()
{
DhApiRenderableBoxGroupShading shading = new DhApiRenderableBoxGroupShading();
shading.setDefaultShaded();
return shading;
}
public static DhApiRenderableBoxGroupShading getUnshaded()
{
DhApiRenderableBoxGroupShading shading = new DhApiRenderableBoxGroupShading();
shading.setUnshaded();
return shading;
}
//=========//
// methods //
//=========//
/**
* Directions will have different brightness similar to Minecraft blocks. <br>
* This is a good default for un-lit objects.
*/
public void setDefaultShaded()
{
this.north = 0.8f;
this.south = 0.8f;
this.east = 0.6f;
this.west = 0.6f;
this.top = 1.0f;
this.bottom = 0.5f;
}
/**
* All directions render with the same brightness. <br>
* This is best used for glowing objects like beacons.
*/
public void setUnshaded()
{
this.north = 1.0f;
this.south = 1.0f;
this.east = 1.0f;
this.west = 1.0f;
this.top = 1.0f;
this.bottom = 1.0f;
}
}
@@ -22,7 +22,6 @@ package com.seibel.distanthorizons.coreapi.DependencyInjection;
import com.seibel.distanthorizons.api.interfaces.events.IDhApiEventInjector;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiCancelableEvent;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiEventParam;
import com.seibel.distanthorizons.api.methods.events.interfaces.IDhApiOneTimeEvent;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiCancelableEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
@@ -141,26 +140,7 @@ public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements
// fire each event and record if any of them
// request to cancel the event.
// attempt to clone the event input if possible
// this is done to reduce the likely hood that one event listener
// will make change the event parameter for other listeners
T input = eventInput;
if (eventInput instanceof IDhApiEventParam)
{
try
{
//noinspection unchecked
input = (T) ((IDhApiEventParam) eventInput).copy();
}
catch (Exception e)
{
LOGGER.error("Unable to clone event parameter ["+eventInput.getClass().getSimpleName()+"], error: ["+e.getMessage()+"].", e);
}
}
DhApiEventParam<T> eventParam = createEventParamWrapper(event, input);
DhApiEventParam<T> eventParam = createEventParamWrapper(event, eventInput);
event.fireEvent(eventParam);
if (eventParam instanceof DhApiCancelableEventParam)
@@ -34,16 +34,16 @@ public final class ModInfo
public static final String NAME = "DistantHorizons";
/** Human-readable version of NAME */
public static final String READABLE_NAME = "Distant Horizons";
public static final String VERSION = "2.2.1-a";
public static final String VERSION = "2.0.2-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 = 3;
public static final int API_MAJOR_VERSION = 1;
/** This version should be updated whenever new methods are added to the DH API */
public static final int API_MINOR_VERSION = 0;
public static final int API_MINOR_VERSION = 1;
/** This version should be updated whenever non-breaking fixes are added to the DH API */
public static final int API_PATCH_VERSION = 1;
public static final int API_PATH_VERSION = 0;
public static final String NETWORKING_RESOURCE_NAMESPACE = "distant_horizons";
public static final String MULTIVERSE_PLUGIN_NAMESPACE = "world_control";
@@ -67,11 +67,10 @@ public interface IConfigEntry<T>
* Checks if the option is valid
*
* 0 == valid
* 2 == invalid
* 1 == number too high
* -1 == number too low
*/
byte isValid(); // TODO replace with an enum
byte isValid();
/** Checks if a value is valid */
byte isValid(T value);
@@ -24,12 +24,12 @@ import java.util.Arrays;
/**
* Miscellaneous string helper functions.
*
* @author James Seibel
* @version 2022-7-19
*/
public class StringUtil
{
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
/**
* Returns the n-th index of the given string. <br> <br>
*
@@ -67,6 +67,8 @@ public class StringUtil
return stringBuilder.toString();
}
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
/**
* Converts the given byte array into a hex string representation. <br>
* source: https://stackoverflow.com/a/9855338
@@ -83,20 +85,4 @@ public class StringUtil
return new String(hexChars);
}
/**
* Returns a shortened version of the given string that is no longer than maxLength. <br>
* If null returns the empty string.
*/
public static String shortenString(String str, int maxLength)
{
if (str == null)
{
return "";
}
else
{
return str.substring(0, Math.min(str.length(), maxLength));
}
}
}
@@ -19,7 +19,7 @@
package com.seibel.distanthorizons.coreapi.util.converters;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRendererMode;
import com.seibel.distanthorizons.api.enums.rendering.ERendererMode;
import com.seibel.distanthorizons.coreapi.interfaces.config.IConverter;
/**
@@ -28,17 +28,17 @@ import com.seibel.distanthorizons.coreapi.interfaces.config.IConverter;
* @author James Seibel
* @version 2022-6-30
*/
public class RenderModeEnabledConverter implements IConverter<EDhApiRendererMode, Boolean>
public class RenderModeEnabledConverter implements IConverter<ERendererMode, Boolean>
{
@Override public EDhApiRendererMode convertToCoreType(Boolean renderingEnabled)
@Override public ERendererMode convertToCoreType(Boolean renderingEnabled)
{
return renderingEnabled ? EDhApiRendererMode.DEFAULT : EDhApiRendererMode.DISABLED;
return renderingEnabled ? ERendererMode.DEFAULT : ERendererMode.DISABLED;
}
@Override public Boolean convertToApiType(EDhApiRendererMode renderingMode)
@Override public Boolean convertToApiType(ERendererMode renderingMode)
{
return renderingMode == EDhApiRendererMode.DEFAULT;
return renderingMode == ERendererMode.DEFAULT;
}
}
@@ -17,55 +17,46 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.api.objects.math;
package com.seibel.distanthorizons.coreapi.util.math;
import com.seibel.distanthorizons.api.interfaces.util.IDhApiCopyable;
import org.joml.Matrix4f;
import org.joml.Matrix4fc;
import java.nio.FloatBuffer;
/**
* An (almost) exact copy of Minecraft's 1.16.5
* implementation of a 4x4 float matrix. <br><br>
* implementation of a 4x4 float matrix.
*
* <code>
* m00, m10, m20, m30, <br>
* m01, m11, m21, m31, <br>
* m02, m12, m22, m32, <br>
* m03, m13, m23, m33 <br>
* </code>
*
* @author James Seibel
* @version 2024-6-30
* @version 11-11-2021
*/
public class DhApiMat4f implements IDhApiCopyable
public class Mat4f
{
public float m00;
public float m01;
public float m02;
public float m03;
public float m10;
public float m11;
public float m12;
public float m13;
public float m20;
public float m21;
public float m22;
public float m23;
public float m30;
public float m31;
public float m32;
public float m33;
private float m00;
private float m01;
private float m02;
private float m03;
private float m10;
private float m11;
private float m12;
private float m13;
private float m20;
private float m21;
private float m22;
private float m23;
private float m30;
private float m31;
private float m32;
private float m33;
public Mat4f()
{
}
//==============//
// constructors //
//==============//
public DhApiMat4f() { /* all values are 0 */ }
public DhApiMat4f(DhApiMat4f sourceMatrix)
public Mat4f(Mat4f sourceMatrix)
{
this.m00 = sourceMatrix.m00;
this.m01 = sourceMatrix.m01;
@@ -85,36 +76,163 @@ public class DhApiMat4f implements IDhApiCopyable
this.m33 = sourceMatrix.m33;
}
/** Expects the values of the input array to be in row major order (AKA rows then columns) */
public DhApiMat4f(float[] values)
public Mat4f(Matrix4fc sourceMatrix) { this(convertJomlMatrixToArray(sourceMatrix)); }
private static float[] convertJomlMatrixToArray(Matrix4fc sourceMatrix)
{
m00 = values[0];
m01 = values[1];
m02 = values[2];
m03 = values[3];
FloatBuffer buffer = FloatBuffer.allocate(16);
m10 = values[4];
m11 = values[5];
m12 = values[6];
m13 = values[7];
buffer.put(bufferIndex(0, 0), sourceMatrix.m00());
buffer.put(bufferIndex(0, 1), sourceMatrix.m01());
buffer.put(bufferIndex(0, 2), sourceMatrix.m02());
buffer.put(bufferIndex(0, 3), sourceMatrix.m03());
buffer.put(bufferIndex(1, 0), sourceMatrix.m10());
buffer.put(bufferIndex(1, 1), sourceMatrix.m11());
buffer.put(bufferIndex(1, 2), sourceMatrix.m12());
buffer.put(bufferIndex(1, 3), sourceMatrix.m13());
buffer.put(bufferIndex(2, 0), sourceMatrix.m20());
buffer.put(bufferIndex(2, 1), sourceMatrix.m21());
buffer.put(bufferIndex(2, 2), sourceMatrix.m22());
buffer.put(bufferIndex(2, 3), sourceMatrix.m23());
buffer.put(bufferIndex(3, 0), sourceMatrix.m30());
buffer.put(bufferIndex(3, 1), sourceMatrix.m31());
buffer.put(bufferIndex(3, 2), sourceMatrix.m32());
buffer.put(bufferIndex(3, 3), sourceMatrix.m33());
m20 = values[8];
m21 = values[9];
m22 = values[10];
m23 = values[11];
m30 = values[12];
m31 = values[13];
m32 = values[14];
m33 = values[15];
return buffer.array();
}
/* Quaternions are not currently needed/implemented
public Matrix4float(Quaternion p_i48104_1_)
{
float f = p_i48104_1_.i();
float f1 = p_i48104_1_.j();
float f2 = p_i48104_1_.k();
float f3 = p_i48104_1_.r();
float f4 = 2.0F * f * f;
float f5 = 2.0F * f1 * f1;
float f6 = 2.0F * f2 * f2;
this.m00 = 1.0F - f5 - f6;
this.m11 = 1.0F - f6 - f4;
this.m22 = 1.0F - f4 - f5;
this.m33 = 1.0F;
float f7 = f * f1;
float f8 = f1 * f2;
float f9 = f2 * f;
float f10 = f * f3;
float f11 = f1 * f3;
float f12 = f2 * f3;
this.m10 = 2.0F * (f7 + f12);
this.m01 = 2.0F * (f7 - f12);
this.m20 = 2.0F * (f9 - f11);
this.m02 = 2.0F * (f9 + f11);
this.m21 = 2.0F * (f8 + f10);
this.m12 = 2.0F * (f8 - f10);
}
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
else if (obj != null && this.getClass() == obj.getClass())
{
Mat4f otherMatrix = (Mat4f) obj;
return Float.compare(otherMatrix.m00, this.m00) == 0
&& Float.compare(otherMatrix.m01, this.m01) == 0
&& Float.compare(otherMatrix.m02, this.m02) == 0
&& Float.compare(otherMatrix.m03, this.m03) == 0
&& Float.compare(otherMatrix.m10, this.m10) == 0
&& Float.compare(otherMatrix.m11, this.m11) == 0
&& Float.compare(otherMatrix.m12, this.m12) == 0
&& Float.compare(otherMatrix.m13, this.m13) == 0
&& Float.compare(otherMatrix.m20, this.m20) == 0
&& Float.compare(otherMatrix.m21, this.m21) == 0
&& Float.compare(otherMatrix.m22, this.m22) == 0
&& Float.compare(otherMatrix.m23, this.m23) == 0
&& Float.compare(otherMatrix.m30, this.m30) == 0
&& Float.compare(otherMatrix.m31, this.m31) == 0
&& Float.compare(otherMatrix.m32, this.m32) == 0
&& Float.compare(otherMatrix.m33, this.m33) == 0;
}
else
{
return false;
}
}
@Override
public int hashCode()
{
int i = this.m00 != 0.0F ? Float.floatToIntBits(this.m00) : 0;
i = 31 * i + (this.m01 != 0.0F ? Float.floatToIntBits(this.m01) : 0);
i = 31 * i + (this.m02 != 0.0F ? Float.floatToIntBits(this.m02) : 0);
i = 31 * i + (this.m03 != 0.0F ? Float.floatToIntBits(this.m03) : 0);
i = 31 * i + (this.m10 != 0.0F ? Float.floatToIntBits(this.m10) : 0);
i = 31 * i + (this.m11 != 0.0F ? Float.floatToIntBits(this.m11) : 0);
i = 31 * i + (this.m12 != 0.0F ? Float.floatToIntBits(this.m12) : 0);
i = 31 * i + (this.m13 != 0.0F ? Float.floatToIntBits(this.m13) : 0);
i = 31 * i + (this.m20 != 0.0F ? Float.floatToIntBits(this.m20) : 0);
i = 31 * i + (this.m21 != 0.0F ? Float.floatToIntBits(this.m21) : 0);
i = 31 * i + (this.m22 != 0.0F ? Float.floatToIntBits(this.m22) : 0);
i = 31 * i + (this.m23 != 0.0F ? Float.floatToIntBits(this.m23) : 0);
i = 31 * i + (this.m30 != 0.0F ? Float.floatToIntBits(this.m30) : 0);
i = 31 * i + (this.m31 != 0.0F ? Float.floatToIntBits(this.m31) : 0);
i = 31 * i + (this.m32 != 0.0F ? Float.floatToIntBits(this.m32) : 0);
return 31 * i + (this.m33 != 0.0F ? Float.floatToIntBits(this.m33) : 0);
}
@Override
public String toString()
{
return "Matrix4f:\n" +
this.m00 + " " + this.m01 + " " + this.m02 + " " + this.m03 + "\n" +
this.m10 + " " + this.m11 + " " + this.m12 + " " + this.m13 + "\n" +
this.m20 + " " + this.m21 + " " + this.m22 + " " + this.m23 + "\n" +
this.m30 + " " + this.m31 + " " + this.m32 + " " + this.m33 + "\n";
}
//=========//
// methods //
//=========//
public void store(FloatBuffer floatBuffer)
{
floatBuffer.put(bufferIndex(0, 0), this.m00);
floatBuffer.put(bufferIndex(0, 1), this.m01);
floatBuffer.put(bufferIndex(0, 2), this.m02);
floatBuffer.put(bufferIndex(0, 3), this.m03);
floatBuffer.put(bufferIndex(1, 0), this.m10);
floatBuffer.put(bufferIndex(1, 1), this.m11);
floatBuffer.put(bufferIndex(1, 2), this.m12);
floatBuffer.put(bufferIndex(1, 3), this.m13);
floatBuffer.put(bufferIndex(2, 0), this.m20);
floatBuffer.put(bufferIndex(2, 1), this.m21);
floatBuffer.put(bufferIndex(2, 2), this.m22);
floatBuffer.put(bufferIndex(2, 3), this.m23);
floatBuffer.put(bufferIndex(3, 0), this.m30);
floatBuffer.put(bufferIndex(3, 1), this.m31);
floatBuffer.put(bufferIndex(3, 2), this.m32);
floatBuffer.put(bufferIndex(3, 3), this.m33);
}
public Matrix4f createJomlMatrix()
{
return new Matrix4f(
this.m00, this.m10, this.m20, this.m30,
this.m01, this.m11, this.m21, this.m31,
this.m02, this.m12, this.m22, this.m32,
this.m03, this.m13, this.m23, this.m33
);
}
private static int bufferIndex(int xIndex, int zIndex)
{
return (zIndex * 4) + xIndex;
}
public void setIdentity()
{
@@ -223,7 +341,7 @@ public class DhApiMat4f implements IDhApiCopyable
}
}
public void multiply(DhApiMat4f multMatrix)
public void multiply(Mat4f multMatrix)
{
float f = this.m00 * multMatrix.m00 + this.m01 * multMatrix.m10 + this.m02 * multMatrix.m20 + this.m03 * multMatrix.m30;
float f1 = this.m00 * multMatrix.m01 + this.m01 * multMatrix.m11 + this.m02 * multMatrix.m21 + this.m03 * multMatrix.m31;
@@ -259,6 +377,13 @@ public class DhApiMat4f implements IDhApiCopyable
this.m33 = f15;
}
/* Quaternions aren't currently needed/implemented
public void multiply(Quaternion p_226596_1_)
{
this.multiply(new Matrix4f(p_226596_1_));
}
*/
public void multiply(float scalar)
{
this.m00 *= scalar;
@@ -279,6 +404,81 @@ public class DhApiMat4f implements IDhApiCopyable
this.m33 *= scalar;
}
public static Mat4f perspective(double fov, float widthHeightRatio, float nearClipPlane, float farClipPlane)
{
float f = (float) (1.0D / Math.tan(fov * ((float) Math.PI / 180F) / 2.0D));
Mat4f matrix = new Mat4f();
matrix.m00 = f / widthHeightRatio;
matrix.m11 = f;
matrix.m22 = (farClipPlane + nearClipPlane) / (nearClipPlane - farClipPlane);
matrix.m32 = -1.0F;
matrix.m23 = 2.0F * farClipPlane * nearClipPlane / (nearClipPlane - farClipPlane);
return matrix;
}
/* not currently needed/implemented
* Also the parameter names should be double checked as they may be incorrect
public static Matrix4Float orthographic(float left, float right, float top, float bottom)
{
Matrix4Float matrix4f = new Matrix4Float();
matrix4f.m00 = 2.0F / left;
matrix4f.m11 = 2.0F / right;
float f = bottom - top;
matrix4f.m22 = -2.0F / f;
matrix4f.m33 = 1.0F;
matrix4f.m03 = -1.0F;
matrix4f.m13 = -1.0F;
matrix4f.m23 = -(bottom + top) / f;
return matrix4f;
}
*/
/**
* 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)
*/
public void translate(Vec3f vec)
{
this.m03 += vec.x;
this.m13 += vec.y;
this.m23 += vec.z;
}
/** originally "translate" from Minecraft's MatrixStack */
public void multiplyTranslationMatrix(double x, double y, double z)
{
multiply(createTranslateMatrix((float) x, (float) y, (float) z));
}
public Mat4f copy()
{
return new Mat4f(this);
}
public static Mat4f createScaleMatrix(float x, float y, float z)
{
Mat4f matrix = new Mat4f();
matrix.m00 = x;
matrix.m11 = y;
matrix.m22 = z;
matrix.m33 = 1.0F;
return matrix;
}
public static Mat4f createTranslateMatrix(float x, float y, float z)
{
Mat4f matrix = new Mat4f();
matrix.m00 = 1.0F;
matrix.m11 = 1.0F;
matrix.m22 = 1.0F;
matrix.m33 = 1.0F;
matrix.m03 = x;
matrix.m13 = y;
matrix.m23 = z;
return matrix;
}
@@ -287,8 +487,6 @@ public class DhApiMat4f implements IDhApiCopyable
// methods //
//==================//
private static int getArrayIndex(int xIndex, int zIndex) { return (zIndex * 4) + xIndex; }
/** Returns the values of this matrix in row major order (AKA rows then columns) */
public float[] getValuesAsArray()
{
@@ -315,77 +513,113 @@ public class DhApiMat4f implements IDhApiCopyable
};
}
//================//
// base overrides //
//================//
@Override
public boolean equals(Object obj)
public Vec3f asNonNormalizedLookForwardVector()
{
if (this == obj)
{
return true;
}
else if (obj != null && this.getClass() == obj.getClass())
{
DhApiMat4f otherMatrix = (DhApiMat4f) obj;
return Float.compare(otherMatrix.m00, this.m00) == 0
&& Float.compare(otherMatrix.m01, this.m01) == 0
&& Float.compare(otherMatrix.m02, this.m02) == 0
&& Float.compare(otherMatrix.m03, this.m03) == 0
&& Float.compare(otherMatrix.m10, this.m10) == 0
&& Float.compare(otherMatrix.m11, this.m11) == 0
&& Float.compare(otherMatrix.m12, this.m12) == 0
&& Float.compare(otherMatrix.m13, this.m13) == 0
&& Float.compare(otherMatrix.m20, this.m20) == 0
&& Float.compare(otherMatrix.m21, this.m21) == 0
&& Float.compare(otherMatrix.m22, this.m22) == 0
&& Float.compare(otherMatrix.m23, this.m23) == 0
&& Float.compare(otherMatrix.m30, this.m30) == 0
&& Float.compare(otherMatrix.m31, this.m31) == 0
&& Float.compare(otherMatrix.m32, this.m32) == 0
&& Float.compare(otherMatrix.m33, this.m33) == 0;
}
else
{
return false;
}
return new Vec3f(this.m02, this.m12, this.m22);
}
@Override
public int hashCode()
//===============//
// Forge methods //
//===============//
public Mat4f(float[] values)
{
int i = this.m00 != 0.0F ? Float.floatToIntBits(this.m00) : 0;
i = 31 * i + (this.m01 != 0.0F ? Float.floatToIntBits(this.m01) : 0);
i = 31 * i + (this.m02 != 0.0F ? Float.floatToIntBits(this.m02) : 0);
i = 31 * i + (this.m03 != 0.0F ? Float.floatToIntBits(this.m03) : 0);
i = 31 * i + (this.m10 != 0.0F ? Float.floatToIntBits(this.m10) : 0);
i = 31 * i + (this.m11 != 0.0F ? Float.floatToIntBits(this.m11) : 0);
i = 31 * i + (this.m12 != 0.0F ? Float.floatToIntBits(this.m12) : 0);
i = 31 * i + (this.m13 != 0.0F ? Float.floatToIntBits(this.m13) : 0);
i = 31 * i + (this.m20 != 0.0F ? Float.floatToIntBits(this.m20) : 0);
i = 31 * i + (this.m21 != 0.0F ? Float.floatToIntBits(this.m21) : 0);
i = 31 * i + (this.m22 != 0.0F ? Float.floatToIntBits(this.m22) : 0);
i = 31 * i + (this.m23 != 0.0F ? Float.floatToIntBits(this.m23) : 0);
i = 31 * i + (this.m30 != 0.0F ? Float.floatToIntBits(this.m30) : 0);
i = 31 * i + (this.m31 != 0.0F ? Float.floatToIntBits(this.m31) : 0);
i = 31 * i + (this.m32 != 0.0F ? Float.floatToIntBits(this.m32) : 0);
return 31 * i + (this.m33 != 0.0F ? Float.floatToIntBits(this.m33) : 0);
m00 = values[0];
m01 = values[1];
m02 = values[2];
m03 = values[3];
m10 = values[4];
m11 = values[5];
m12 = values[6];
m13 = values[7];
m20 = values[8];
m21 = values[9];
m22 = values[10];
m23 = values[11];
m30 = values[12];
m31 = values[13];
m32 = values[14];
m33 = values[15];
}
@Override
public String toString()
public Mat4f(FloatBuffer buffer)
{
return "Matrix4f:\n" +
this.m00 + " " + this.m01 + " " + this.m02 + " " + this.m03 + "\n" +
this.m10 + " " + this.m11 + " " + this.m12 + " " + this.m13 + "\n" +
this.m20 + " " + this.m21 + " " + this.m22 + " " + this.m23 + "\n" +
this.m30 + " " + this.m31 + " " + this.m32 + " " + this.m33 + "\n";
this(buffer.array());
}
@Override
public DhApiMat4f copy() { return new DhApiMat4f(this); }
public void set(Mat4f mat)
{
this.m00 = mat.m00;
this.m01 = mat.m01;
this.m02 = mat.m02;
this.m03 = mat.m03;
this.m10 = mat.m10;
this.m11 = mat.m11;
this.m12 = mat.m12;
this.m13 = mat.m13;
this.m20 = mat.m20;
this.m21 = mat.m21;
this.m22 = mat.m22;
this.m23 = mat.m23;
this.m30 = mat.m30;
this.m31 = mat.m31;
this.m32 = mat.m32;
this.m33 = mat.m33;
}
public void add(Mat4f other)
{
m00 += other.m00;
m01 += other.m01;
m02 += other.m02;
m03 += other.m03;
m10 += other.m10;
m11 += other.m11;
m12 += other.m12;
m13 += other.m13;
m20 += other.m20;
m21 += other.m21;
m22 += other.m22;
m23 += other.m23;
m30 += other.m30;
m31 += other.m31;
m32 += other.m32;
m33 += other.m33;
}
public void multiplyBackward(Mat4f other)
{
Mat4f copy = other.copy();
copy.multiply(this);
this.set(copy);
}
public void setTranslation(float x, float y, float z)
{
this.m00 = 1.0F;
this.m11 = 1.0F;
this.m22 = 1.0F;
this.m33 = 1.0F;
this.m03 = x;
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.
*
* @param nearClip New near clipping plane value.
* @param farClip New far clipping plane value.
*/
public void setClipPlanes(float nearClip, float farClip)
{
//convert to matrix values, formula copied from a textbook / openGL specification.
float matNearClip = -((farClip + nearClip) / (farClip - nearClip));
float matFarClip = -((2 * farClip * nearClip) / (farClip - nearClip));
//set new values for the clip planes.
this.m22 = matNearClip;
this.m23 = matFarClip;
}
}
@@ -17,10 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.core.util.math;
package com.seibel.distanthorizons.coreapi.util.math;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.coreapi.util.MathUtil;
/**
@@ -31,7 +29,7 @@ import com.seibel.distanthorizons.coreapi.util.MathUtil;
* @author James Seibel
* @version 11-18-2021
*/
public class Vec3d extends DhApiVec3d
public class Vec3d
{
public static Vec3d XNeg = new Vec3d(-1.0F, 0.0F, 0.0F);
public static Vec3d XPos = new Vec3d(1.0F, 0.0F, 0.0F);
@@ -42,13 +40,16 @@ public class Vec3d extends DhApiVec3d
public static final Vec3d ZERO_VECTOR = new Vec3d(0.0D, 0.0D, 0.0D);
public double x;
public double y;
public double z;
//==============//
// constructors //
//==============//
public Vec3d() { }
public Vec3d()
{
}
public Vec3d(double x, double y, double z)
{
@@ -57,11 +58,47 @@ public class Vec3d extends DhApiVec3d
this.z = z;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
else if (obj != null && this.getClass() == obj.getClass())
{
Vec3d Vec3f = (Vec3d) obj;
if (Double.compare(Vec3f.x, this.x) != 0)
{
return false;
}
else if (Double.compare(Vec3f.y, this.y) != 0)
{
return false;
}
else
{
return Double.compare(Vec3f.z, this.z) == 0;
}
}
else
{
return false;
}
}
//=========//
// methods //
//=========//
@Override
public int hashCode()
{
long longVal = Double.doubleToLongBits(this.x);
int intVal = (int) (longVal ^ longVal >>> 32);
longVal = Double.doubleToLongBits(this.y);
intVal = 31 * intVal + (int) (longVal ^ longVal >>> 32);
longVal = Double.doubleToLongBits(this.z);
return 31 * intVal + (int) (longVal ^ longVal >>> 32);
}
public void mul(double scalar)
{
@@ -112,7 +149,10 @@ public class Vec3d extends DhApiVec3d
this.z -= vector.z;
}
public double dotProduct(Vec3d vector) { return this.x * vector.x + this.y * vector.y + this.z * vector.z; }
public double dotProduct(Vec3d vector)
{
return this.x * vector.x + this.y * vector.y + this.z * vector.z;
}
public Vec3d normalize()
{
@@ -133,9 +173,80 @@ public class Vec3d extends DhApiVec3d
this.z = f * f4 - f1 * f3;
}
public Vec3d copy() { return new Vec3d(this.x, this.y, this.z); }
/* Matrix3f is not currently needed/implemented
public void transform(Matrix3f p_229188_1_)
{
double f = this.x;
double f1 = this.y;
double f2 = this.z;
this.x = p_229188_1_.m00 * f + p_229188_1_.m01 * f1 + p_229188_1_.m02 * f2;
this.y = p_229188_1_.m10 * f + p_229188_1_.m11 * f1 + p_229188_1_.m12 * f2;
this.z = p_229188_1_.m20 * f + p_229188_1_.m21 * f1 + p_229188_1_.m22 * f2;
}
*/
public Vec3d(double[] values) { this.set(values); }
/* Quaternions are not currently needed/implemented
public void transform(Quaternion p_214905_1_)
{
Quaternion quaternion = new Quaternion(p_214905_1_);
quaternion.mul(new Quaternion(this.x(), this.y(), this.z(), 0.0F));
Quaternion quaternion1 = new Quaternion(p_214905_1_);
quaternion1.conj();
quaternion.mul(quaternion1);
this.set(quaternion.i(), quaternion.j(), quaternion.k());
}
*/
/* not currently needed
* percent may actually be partial ticks (which is available when rendering)
public void linearInterp(Vec3f resultingVector, double percent)
{
double f = 1.0F - percent;
this.x = this.x * f + resultingVector.x * percent;
this.y = this.y * f + resultingVector.y * percent;
this.z = this.z * f + resultingVector.z * percent;
}
*/
/* Quaternions are not currently needed/implemented
public Quaternion rotation(double p_229193_1_)
{
return new Quaternion(this, p_229193_1_, false);
}
@OnlyIn(Dist.CLIENT)
public Quaternion rotationDegrees(double p_229187_1_)
{
return new Quaternion(this, p_229187_1_, true);
}
*/
public Vec3d copy()
{
return new Vec3d(this.x, this.y, this.z);
}
/* not currently needed/implemented
public void map(double2doubleFunction p_229191_1_)
{
this.x = p_229191_1_.get(this.x);
this.y = p_229191_1_.get(this.y);
this.z = p_229191_1_.get(this.z);
}
*/
@Override
public String toString()
{
return "[" + this.x + ", " + this.y + ", " + this.z + "]";
}
// Forge start
public Vec3d(double[] values)
{
set(values);
}
public void set(double[] values)
{
@@ -144,31 +255,4 @@ public class Vec3d extends DhApiVec3d
this.z = values[2];
}
public static double getManhattanDistance(DhApiVec3d a, DhApiVec3d b)
{
return Math.abs(a.x - b.x)
+ Math.abs(a.y - b.y)
+ Math.abs(a.z - b.z);
}
public static double getDistance(DhApiVec3d a, DhApiVec3d b)
{
return Math.sqrt(Math.pow(a.x - b.x, 2)
+ Math.pow(a.y - b.y, 2)
+ Math.pow(a.z - b.z, 2));
}
/** slightly faster version of {@link Vec3d#getDistance} */
public static double getSquaredDistance(DhApiVec3d a, DhApiVec3d b)
{
return Math.pow(a.x - b.x, 2)
+ Math.pow(a.y - b.y, 2)
+ Math.pow(a.z - b.z, 2);
}
/** Gets the distance between points A and B, ignoring Y height. */
public static double getHorizontalDistance(DhApiVec3d a, DhApiVec3d b)
{
return Math.sqrt(Math.pow(a.x - b.x, 2)
+ Math.pow(a.z - b.z, 2));
}
}
@@ -0,0 +1,263 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* 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.util.math;
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
*/
public class Vec3f
{
public static Vec3f XNeg = new Vec3f(-1.0F, 0.0F, 0.0F);
public static Vec3f XPos = new Vec3f(1.0F, 0.0F, 0.0F);
public static Vec3f YNeg = new Vec3f(0.0F, -1.0F, 0.0F);
public static Vec3f YPos = new Vec3f(0.0F, 1.0F, 0.0F);
public static Vec3f ZNeg = new Vec3f(0.0F, 0.0F, -1.0F);
public static Vec3f ZPos = new Vec3f(0.0F, 0.0F, 1.0F);
public float x;
public float y;
public float z;
public Vec3f()
{
}
public Vec3f(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
else if (obj != null && this.getClass() == obj.getClass())
{
Vec3f Vec3f = (Vec3f) obj;
if (Float.compare(Vec3f.x, this.x) != 0)
{
return false;
}
else if (Float.compare(Vec3f.y, this.y) != 0)
{
return false;
}
else
{
return Float.compare(Vec3f.z, this.z) == 0;
}
}
else
{
return false;
}
}
@Override
public int hashCode()
{
int i = Float.floatToIntBits(this.x);
i = 31 * i + Float.floatToIntBits(this.y);
return 31 * i + Float.floatToIntBits(this.z);
}
public void mul(float scalar)
{
this.x *= scalar;
this.y *= scalar;
this.z *= scalar;
}
public void mul(float x, float y, float z)
{
this.x *= x;
this.y *= y;
this.z *= z;
}
public void clamp(float min, float max)
{
this.x = MathUtil.clamp(min, this.x, max);
this.y = MathUtil.clamp(min, this.y, max);
this.z = MathUtil.clamp(min, this.z, max);
}
public void set(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
public void add(float x, float y, float z)
{
this.x += x;
this.y += y;
this.z += z;
}
public void add(Vec3f vector)
{
this.x += vector.x;
this.y += vector.y;
this.z += vector.z;
}
public void subtract(Vec3f vector)
{
this.x -= vector.x;
this.y -= vector.y;
this.z -= vector.z;
}
public float dotProduct(Vec3f vector)
{
return this.x * vector.x + this.y * vector.y + this.z * vector.z;
}
/** Returns true if normalization had to be done */
public boolean normalize()
{
float squaredSum = this.x * this.x + this.y * this.y + this.z * this.z;
if (squaredSum < 1.0E-5D)
{
return false;
}
else
{
float f1 = MathUtil.fastInvSqrt(squaredSum);
this.x *= f1;
this.y *= f1;
this.z *= f1;
return true;
}
}
public void crossProduct(Vec3f vector)
{
float f = this.x;
float f1 = this.y;
float f2 = this.z;
float f3 = vector.x;
float f4 = vector.y;
float f5 = vector.z;
this.x = f1 * f5 - f2 * f4;
this.y = f2 * f3 - f * f5;
this.z = f * f4 - f1 * f3;
}
/* Matrix3f is not currently needed/implemented
public void transform(Matrix3f p_229188_1_)
{
float f = this.x;
float f1 = this.y;
float f2 = this.z;
this.x = p_229188_1_.m00 * f + p_229188_1_.m01 * f1 + p_229188_1_.m02 * f2;
this.y = p_229188_1_.m10 * f + p_229188_1_.m11 * f1 + p_229188_1_.m12 * f2;
this.z = p_229188_1_.m20 * f + p_229188_1_.m21 * f1 + p_229188_1_.m22 * f2;
}
*/
/* Quaternions are not currently needed/implemented
public void transform(Quaternion p_214905_1_)
{
Quaternion quaternion = new Quaternion(p_214905_1_);
quaternion.mul(new Quaternion(this.x(), this.y(), this.z(), 0.0F));
Quaternion quaternion1 = new Quaternion(p_214905_1_);
quaternion1.conj();
quaternion.mul(quaternion1);
this.set(quaternion.i(), quaternion.j(), quaternion.k());
}
*/
/* not currently needed
* percent may actually be partial ticks (which is available when rendering)
public void linearInterp(Vec3f resultingVector, float percent)
{
float f = 1.0F - percent;
this.x = this.x * f + resultingVector.x * percent;
this.y = this.y * f + resultingVector.y * percent;
this.z = this.z * f + resultingVector.z * percent;
}
*/
/* Quaternions are not currently needed/implemented
public Quaternion rotation(float p_229193_1_)
{
return new Quaternion(this, p_229193_1_, false);
}
@OnlyIn(Dist.CLIENT)
public Quaternion rotationDegrees(float p_229187_1_)
{
return new Quaternion(this, p_229187_1_, true);
}
*/
public Vec3f copy()
{
return new Vec3f(this.x, this.y, this.z);
}
/* not currently needed/implemented
public void map(Float2FloatFunction p_229191_1_)
{
this.x = p_229191_1_.get(this.x);
this.y = p_229191_1_.get(this.y);
this.z = p_229191_1_.get(this.z);
}
*/
@Override
public String toString()
{
return "[" + this.x + ", " + this.y + ", " + this.z + "]";
}
// Forge start
public Vec3f(float[] values)
{
set(values);
}
public void set(float[] values)
{
this.x = values[0];
this.y = values[1];
this.z = values[2];
}
}
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.core.util.math;
package com.seibel.distanthorizons.coreapi.util.math;
import com.seibel.distanthorizons.coreapi.util.MathUtil;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
@@ -28,7 +28,7 @@ import org.junit.Test;
* @author James Seibel
* @version 2022-9-5
*/
public class ExampleApiTest
public class ExampleTest
{
@Test

Some files were not shown because too many files have changed in this diff Show More