Flip API -> Core dependency to Core -> API

Very rough, a decent amount of the API isn't hooked up to anything.
This commit is contained in:
James Seibel
2022-09-12 21:53:55 -05:00
parent 1bfc6db8b4
commit 4f1203b32c
120 changed files with 736 additions and 3097 deletions
@@ -1,7 +1,6 @@
package com.seibel.lod.api;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.datatype.full.FullDataSource;
/**
* This holds API methods related to version numbers and other unchanging endpoints.
@@ -39,10 +38,5 @@ public class DhApiMain
{
return ModInfo.PROTOCOL_VERSION;
}
/** Returns the LOD file version. */
public static int getLodFileFormatVersion()
{
return FullDataSource.LATEST_VERSION;
}
}
@@ -1,40 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.enums;
import com.seibel.lod.api.items.enums.config.DhApiConfigEnumAssembly;
import com.seibel.lod.api.items.enums.worldGeneration.DhApiWorldGenerationEnumAssembly;
/**
* Assembly classes are used to reference the package they are in.
*
* @author James Seibel
* @version 2022-7-18
*/
public class DhApiEnumAssembly
{
// These variables are added in order to load each package into the JVM's class loader.
// This is done so they can be found via reflection.
private static final DhApiWorldGenerationEnumAssembly worldGenerationAssembly = new DhApiWorldGenerationEnumAssembly();
private static final DhApiConfigEnumAssembly configAssembly = new DhApiConfigEnumAssembly();
/** All DH API enums should have this prefix */
public static final String API_ENUM_PREFIX = "EDhApi";
}
@@ -1,31 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* Assembly classes are used to reference the package they are in.
*
* @author James Seibel
* @version 2022-7-13
*/
public class DhApiConfigEnumAssembly
{
}
@@ -1,53 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* NONE, <br>
* NON_FULL, <br>
* NO_COLLISION, <br>
* BOTH, <br>
*
* @author Leonardo Amato
* @version 2022-7-1
*/
public enum EDhApiBlocksToAvoid
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NONE(false, false),
NON_FULL(true, false),
NO_COLLISION(false, true),
BOTH(true, true);
public final boolean nonFull;
public final boolean noCollision;
EDhApiBlocksToAvoid(boolean nonFull, boolean noCollision)
{
this.nonFull = nonFull;
this.noCollision = noCollision;
}
}
@@ -1,39 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.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
*/
public enum EDhApiBufferRebuildTimes
{
CONSTANT,
FREQUENT,
NORMAL,
RARE;
}
@@ -1,67 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* OFF, <br>
* SHOW_WIREFRAME, <br>
* SHOW_DETAIL, <br>
* SHOW_DETAIL_WIREFRAME, <br>
* SHOW_GENMODE, <br>
* SHOW_GENMODE_WIREFRAME, <br>
* SHOW_OVERLAPPING_QUADS, <br>
* SHOW_OVERLAPPING_QUADS_WIREFRAME, <br>
*
* @author Leetom
* @author James Seibel
* @version 2022-7-2
*/
public enum EDhApiDebugMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** LODs are rendered normally */
OFF,
/** LOD draws in wireframe. */
SHOW_WIREFRAME,
/** LOD colors are based on their detail */
SHOW_DETAIL,
/** LOD colors are based on their detail, and draws in wireframe. */
SHOW_DETAIL_WIREFRAME,
/** LOD colors are based on their gen mode. */
SHOW_GENMODE,
/** LOD colors are based on their gen mode, and draws in wireframe. */
SHOW_GENMODE_WIREFRAME,
/** Only draw overlapping LOD quads. */
SHOW_OVERLAPPING_QUADS,
/** Only draw overlapping LOD quads, and draws in wireframe. */
SHOW_OVERLAPPING_QUADS_WIREFRAME;
}
@@ -1,88 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* NONE <br>
* BIOME_ONLY <br>
* BIOME_ONLY_SIMULATE_HEIGHT <br>
* SURFACE <br>
* FEATURES <br>
* FULL <br><br>
*
* In order of fastest to slowest.
*
* @author James Seibel
* @author Leonardo Amato
* @version 2022-7-1
*/
public enum EDhApiDistanceGenerationMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** Don't generate anything except already existing chunks */
NONE,
/**
* Only generate the biomes and use biome
* grass/foliage color, water color, or ice color
* to generate the color. <br>
* Doesn't generate height, everything is shown at sea level. <br>
* Multithreaded - Fastest (2-5 ms)
*/
BIOME_ONLY,
/**
* Same as BIOME_ONLY, except instead
* of always using sea level as the LOD height
* different biome types (mountain, ocean, forest, etc.)
* use predetermined heights to simulate having height data.
*/
BIOME_ONLY_SIMULATE_HEIGHT,
/**
* Generate the world surface,
* this does NOT include caves, trees,
* or structures. <br>
* Multithreaded - Faster (10-20 ms)
*/
SURFACE,
/**
* Generate including structures.
* NOTE: This may cause world generation bugs or instability,
* since some features can cause concurrentModification exceptions. <br>
* Multithreaded - Fast (15-20 ms)
*/
FEATURES,
/**
* Ask the server to generate/load each chunk.
* This is the most compatible, but causes server/simulation lag.
* This will also show player made structures if you
* are adding the mod on a pre-existing world. <br>
* Single-threaded - Slow (15-50 ms, with spikes up to 200 ms)
*/
FULL;
}
@@ -1,54 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2022 Tom Lee (TomTheFurry)
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* AUTO <br>
* SMOOTH_DROPOFF <br>
* PERFORMANCE_FOCUSED <br> <br>
*
* Determines how lod level drop off should be done
*
* @author Tom Lee
* @version 7-1-2022
*/
public enum EDhApiDropoffQuality
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** SMOOTH_DROPOFF when <128 lod view distance, or PERFORMANCE_FOCUSED otherwise */
AUTO(-1),
SMOOTH_DROPOFF(10),
PERFORMANCE_FOCUSED(0);
public final int fastModeSwitch;
EDhApiDropoffQuality(int fastModeSwitch) {
this.fastModeSwitch = fastModeSwitch;
}
}
@@ -1,46 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* USE_DEFAULT_FOG_COLOR, <br>
* USE_SKY_COLOR, <br>
*
* @author James Seibel
* @version 2022-6-9
*/
public enum EDhApiFogColorMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** Fog uses Minecraft's fog color. */
USE_WORLD_FOG_COLOR,
/**
* Replicates the effect of the clear sky mod.
* Making the fog blend in with the sky better
* For it to look good you need one of the following mods:
* https://www.curseforge.com/minecraft/mc-mods/clear-skies
* https://www.curseforge.com/minecraft/mc-mods/clear-skies-forge-port
*/
USE_SKY_COLOR,
}
@@ -1,39 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* NEAR, <br>
* FAR, <br>
* NEAR_AND_FAR <br>
*
* @author James Seibel
* @version 2022-6-2
*/
public enum EDhApiFogDistance
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
NEAR,
FAR,
NEAR_AND_FAR
}
@@ -1,46 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* USE_OPTIFINE_FOG_SETTING, <br>
* FOG_ENABLED, <br>
* FOG_DISABLED <br>
*
* @author James Seibel
* @version 2022-6-2
*/
public enum EDhApiFogDrawMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* Use whatever Fog setting optifine is using.
* If optifine isn't installed this defaults to FOG_ENABLED.
*/
USE_OPTIFINE_SETTING,
FOG_ENABLED,
FOG_DISABLED;
}
@@ -1,21 +0,0 @@
package com.seibel.lod.api.items.enums.config;
/**
* LINEAR, <br>
* EXPONENTIAL, <br>
* EXPONENTIAL_SQUARED <br>
*
* @author Leetom
* @version 2022-6-30
*/
public enum EDhApiFogFalloff
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
LINEAR,
EXPONENTIAL,
EXPONENTIAL_SQUARED,
}
@@ -1,47 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.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
*/
public enum EDhApiGenerationPriority
{
// 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
}
@@ -1,64 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* AUTO, <br>
* BUFFER_STORAGE, <br>
* SUB_DATA, <br>
* BUFFER_MAPPING, <br>
* DATA <br>
*
* @author Leetom
* @author James Seibel
* @version 2022-7-2
*/
public enum EDhApiGpuUploadMethod
{
/** Picks the best option based on the GPU the user has. */
AUTO,
/**
* Default for NVIDIA if OpenGL 4.5 is supported. <br>
* Fast rendering, no stuttering.
*/
BUFFER_STORAGE,
/**
* Backup option for NVIDIA. <br>
* Fast rendering but may stutter when uploading.
*/
SUB_DATA,
/**
* Default option for AMD/Intel. <br>
* 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.
*/
BUFFER_MAPPING,
/**
* Backup option for AMD/Intel. <br>
* Fast rendering but may stutter when uploading.
*/
DATA;
}
@@ -1,49 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* BASIC <br>
* IGNORE_HEIGHT <br>
* ADDITION <br>
* MAX <br>
* MULTIPLY <br>
* INVERSE_MULTIPLY <br>
* LIMITED_ADDITION <br>
* MULTIPLY_ADDITION <br>
* INVERSE_MULTIPLY_ADDITION <br>
* AVERAGE <br>
*
* @author Leetom
* @version 2022-4-14
*/
public enum EDhApiHeightFogMixMode
{
BASIC,
IGNORE_HEIGHT,
ADDITION,
MAX,
MULTIPLY,
INVERSE_MULTIPLY,
LIMITED_ADDITION,
MULTIPLY_ADDITION,
INVERSE_MULTIPLY_ADDITION,
AVERAGE,
}
@@ -1,57 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* ABOVE_CAMERA, <br>
* BELOW_CAMERA, <br>
* ABOVE_AND_BELOW_CAMERA, <br>
* ABOVE_SET_HEIGHT, <br>
* BELOW_SET_HEIGHT, <br>
* ABOVE_AND_BELOW_SET_HEIGHT, <br>
*
* @author Leetom
* @version 6-30-2022
*/
public enum EDhApiHeightFogMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
ABOVE_CAMERA(true, true, false),
BELOW_CAMERA(true, false, true),
ABOVE_AND_BELOW_CAMERA(true, true, true),
ABOVE_SET_HEIGHT(false, true, false),
BELOW_SET_HEIGHT(false, false, true),
ABOVE_AND_BELOW_SET_HEIGHT(false, true, true);
public final boolean basedOnCamera;
public final boolean above;
public final boolean below;
EDhApiHeightFogMode(boolean basedOnCamera, boolean above, boolean below)
{
this.basedOnCamera = basedOnCamera;
this.above = above;
this.below = below;
}
}
@@ -1,58 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* LOWEST <br>
* LOW <br>
* MEDIUM <br>
* HIGH <br> <br>
*
* this indicates the base of the quadratic function we use for the quality drop-off
*
* @author Leonardo Amato
* @version 9-29-2021
*/
public enum EDhApiHorizontalQuality
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** 1.0 AKA Linear */
LOWEST(1.0f),
/** exponent 1.5 */
LOW(1.5f),
/** exponent 2.0 */
MEDIUM(2.0f),
/** exponent 2.2 */
HIGH(2.2f);
public final double quadraticBase;
EDhApiHorizontalQuality(double distanceUnit)
{
this.quadraticBase = distanceUnit;
}
}
@@ -1,50 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* BLOCK <Br>
* TWO_BLOCKS <Br>
* FOUR_BLOCKS <br>
* HALF_CHUNK <Br>
* CHUNK <br>
*
* @author James Seibel
* @author Leonardo Amato
* @version 2022-7-5
*/
public enum EDhApiHorizontalResolution
{
/** render 256 LODs for each chunk */
BLOCK,
/** render 64 LODs for each chunk */
TWO_BLOCKS,
/** render 16 LODs for each chunk */
FOUR_BLOCKS,
/** render 4 LODs for each chunk */
HALF_CHUNK,
/** render 1 LOD for each chunk */
CHUNK;
}
@@ -1,40 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* FAST, <br>
* FANCY,
*
* @author Leetom
* @version 2022-7-1
*/
public enum EDhApiLightGenerationMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/** Fake light values using a height map */
FAST,
/** Run the lighting engine though the chunk to generate proper light values */
FANCY
}
@@ -1,72 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2022 Tom Lee (TomTheFurry)
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* AUTO, <br>
* NAME_ONLY, <br>
* NAME_IP, <br>
* NAME_IP_PORT, <br> <br>
*
* Determines how the multiplayer folders should be named.
*
* @author James Seibel
* @version 2022-7-1
*/
public enum EDhApiServerFolderNameMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* NAME_IP for LAN connections <Br>
* NAME_IP_PORT for all others
*/
AUTO,
/** Only use the server name */
NAME_ONLY,
/**
* {SERVER_NAME} IP {IP} <br>
* Example: Minecraft Server IP 192.168.1.40
*/
NAME_IP,
/**
* {SERVER_NAME} IP {IP}:{PORT} <br>
* Example: Minecraft Server IP 192.168.1.40:25565
*/
NAME_IP_PORT,
/**
* {SERVER_NAME} IP {IP} <br>
* Example: Minecraft Server IP 192.168.1.40:25565 GameVersion 1.16.5 <Br> <br>
*
* Not normally recommended, since the game version can change if the
* server installs paper or some other jar. <br>
* This is just here to provide backwards compatibility.
*/
NAME_IP_PORT_MC_VERSION;
}
@@ -1,42 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.config;
/**
* LOW, <br>
* MEDIUM, <br>
* HIGH, <br>
* ULTRA <br>
*
* @author Leonardo Amato
* @version 2022-6-9
*/
public enum EDhApiVerticalQuality
{
// Reminder:
// when adding items: up the API minor version
// when removing items: up the API major version
LOW,
MEDIUM,
HIGH,
ULTRA
}
@@ -17,23 +17,47 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.api.items.enums.config;
package com.seibel.lod.api.items.enums.rendering;
/**
* DEFAULT, <br>
* DEBUG, <br>
* DISABLED, <br>
* Default
* Debug
* Disabled
*
* @version 2022-6-2
*/
public enum EDhApiRendererMode
public enum ERendererMode
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
DEFAULT,
DEBUG,
DISABLED;
/** Used by the config GUI to cycle through the available rendering options */
public static ERendererMode next(ERendererMode type)
{
switch (type)
{
case DEFAULT: return DEBUG;
case DEBUG: return DISABLED;
default: return DEFAULT;
}
}
/** Used by the config GUI to cycle through the available rendering options */
public static ERendererMode previous(ERendererMode type)
{
switch (type)
{
case DEFAULT: return DISABLED;
case DEBUG: return DEFAULT;
default: return DEBUG;
}
}
}
@@ -1,31 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.enums.worldGeneration;
/**
* Assembly classes are used to reference the package they are in.
*
* @author James Seibel
* @version 2022-7-14
*/
public class DhApiWorldGenerationEnumAssembly
{
}
@@ -1,7 +1,5 @@
package com.seibel.lod.api.items.interfaces;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.ICoreDhApiUnsafeWrapper;
/**
* The Distant Horizons' API objects can't cover
* every potential use case. Sometimes developers just need
@@ -10,7 +8,7 @@ import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.
* @author James Seibel
* @version 2022-9-6
*/
public interface IDhApiUnsafeWrapper extends ICoreDhApiUnsafeWrapper
public interface IDhApiUnsafeWrapper
{
/**
* Returns the Minecraft object this wrapper contains. <br>
@@ -22,7 +20,6 @@ public interface IDhApiUnsafeWrapper extends ICoreDhApiUnsafeWrapper
* in order to determine what object this method returns for
* the specific version of Minecraft you are developing for.
*/
@Override
public Object getWrappedMcObject_UNSAFE();
}
@@ -4,37 +4,24 @@ import com.seibel.lod.api.items.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiWorldGenThreadMode;
import com.seibel.lod.api.items.interfaces.world.IDhApiChunkWrapper;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.override.worldGenerator.ICoreDhApiWorldGenerator;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.world.ICoreDhApiLevelWrapper;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
import com.seibel.lod.core.enums.worldGeneration.EWorldGenThreadMode;
import com.seibel.lod.core.enums.worldGeneration.EWorldGenerationStep;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
/**
* @author James Seibel
* @version 2022-9-8
*/
public abstract class AbstractDhApiWorldGenerator implements ICoreDhApiWorldGenerator, IDhApiOverrideable
{
private final GenericEnumConverter<EWorldGenThreadMode, EDhApiWorldGenThreadMode> threadModeEnumConverter = new GenericEnumConverter<>(EWorldGenThreadMode.class, EDhApiWorldGenThreadMode.class);
private final GenericEnumConverter<EWorldGenerationStep, EDhApiWorldGenerationStep> generationStepEnumConverter = new GenericEnumConverter<>(EWorldGenerationStep.class, EDhApiWorldGenerationStep.class);
public abstract class AbstractDhApiWorldGenerator implements IDhApiOverrideable
{
/** Returns which thread chunk generation requests can be created on. */
public abstract EDhApiWorldGenThreadMode getThreadingMode();
@Override
public EWorldGenThreadMode getCoreThreadingMode()
public EDhApiWorldGenThreadMode getCoreThreadingMode()
{
return threadModeEnumConverter.convertToCoreType(this.getThreadingMode());
return this.getThreadingMode();
}
public abstract IDhApiChunkWrapper generateChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiWorldGenerationStep maxStepToGenerate);
@Override
public final IChunkWrapper generateCoreChunk(int chunkPosX, int chunkPosZ, ICoreDhApiLevelWrapper serverLevelWrapper, EWorldGenerationStep maxStepToGenerate)
public final IDhApiChunkWrapper generateCoreChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiWorldGenerationStep maxStepToGenerate)
{
// TODO probably need to change the return type
return null; //generateChunk(chunkPosX, chunkPosZ, null, generationStepEnumConverter.convertToApiType(maxStepToGenerate));
@@ -1,8 +1,7 @@
package com.seibel.lod.api.items.interfaces.override;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.override.ICoreDhApiOverrideable;
import com.seibel.lod.core.dependencyInjection.IBindable;
import com.seibel.lod.core.dependencyInjection.OverrideInjector;
import com.seibel.lod.core.dependencyInjection.IOverrideInjector;
/**
* Implemented by all DhApi objects that can be overridden.
@@ -10,13 +9,12 @@ import com.seibel.lod.core.dependencyInjection.OverrideInjector;
* @author James Seibel
* @version 2022-9-5
*/
public interface IDhApiOverrideable extends ICoreDhApiOverrideable, IBindable
public interface IDhApiOverrideable extends IBindable
{
/**
* Returns when this Override should be used. <br>
* For most developers this can be left at the default.
*/
@Override
default int getPriority() { return OverrideInjector.DEFAULT_NON_CORE_OVERRIDE_PRIORITY; }
default int getPriority() { return IOverrideInjector.DEFAULT_NON_CORE_OVERRIDE_PRIORITY; }
}
@@ -0,0 +1,20 @@
package com.seibel.lod.api.items.interfaces.override.worldGenerator;
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiWorldGenThreadMode;
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiWorldGenerationStep;
import com.seibel.lod.api.items.interfaces.override.IDhApiOverrideable;
import com.seibel.lod.api.items.interfaces.world.IDhApiChunkWrapper;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
/**
* @author James Seibel
* @version 2022-9-8
*/
public interface IDhApiWorldGenerator extends IDhApiOverrideable
{
/** Returns which thread chunk generation requests can be created on. */
EDhApiWorldGenThreadMode getCoreThreadingMode();
IDhApiChunkWrapper generateCoreChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiWorldGenerationStep maxStepToGenerate);
}
@@ -20,20 +20,16 @@
package com.seibel.lod.api.items.interfaces.world;
import com.seibel.lod.api.items.interfaces.IDhApiUnsafeWrapper;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.world.ICoreDhApiDimensionTypeWrapper;
/**
* @author James Seibel
* @version 2022-7-14
*/
public interface IDhApiDimensionTypeWrapper extends ICoreDhApiDimensionTypeWrapper, IDhApiUnsafeWrapper
public interface IDhApiDimensionTypeWrapper extends IDhApiUnsafeWrapper
{
@Override
String getDimensionName();
@Override
boolean hasCeiling();
@Override
boolean hasSkyLight();
}
@@ -21,7 +21,6 @@ package com.seibel.lod.api.items.interfaces.world;
import com.seibel.lod.api.items.interfaces.IDhApiUnsafeWrapper;
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiLevelType;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.world.ICoreDhApiLevelWrapper;
/**
* Can be either a Server or Client level.
@@ -29,22 +28,18 @@ import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.
* @author James Seibel
* @version 2022-7-14
*/
public interface IDhApiLevelWrapper extends ICoreDhApiLevelWrapper, IDhApiUnsafeWrapper
public interface IDhApiLevelWrapper extends IDhApiUnsafeWrapper
{
IDhApiDimensionTypeWrapper getDimensionType();
EDhApiLevelType getLevelType();
@Override
boolean hasCeiling();
@Override
boolean hasSkyLight();
@Override
int getHeight();
@Override
default int getMinHeight() { return 0; }
}
@@ -1,202 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.objects.math;
import com.seibel.lod.core.util.math.Mat4f;
/**
* A simple way to store a 4x4 array
* of floats without having to worry
* about remembering which array is columns
* and which one is rows.
* <br>
* Based on Minecraft 1.16's implementation
* of a 4x4 matrix.
*
* @author James Seibel
* @version 2022-8-21
*/
public class DhApiMat4f
{
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 DhApiMat4f()
{
}
public DhApiMat4f(DhApiMat4f sourceMatrix)
{
this.m00 = sourceMatrix.m00;
this.m01 = sourceMatrix.m01;
this.m02 = sourceMatrix.m02;
this.m03 = sourceMatrix.m03;
this.m10 = sourceMatrix.m10;
this.m11 = sourceMatrix.m11;
this.m12 = sourceMatrix.m12;
this.m13 = sourceMatrix.m13;
this.m20 = sourceMatrix.m20;
this.m21 = sourceMatrix.m21;
this.m22 = sourceMatrix.m22;
this.m23 = sourceMatrix.m23;
this.m30 = sourceMatrix.m30;
this.m31 = sourceMatrix.m31;
this.m32 = sourceMatrix.m32;
this.m33 = sourceMatrix.m33;
}
public DhApiMat4f(float[] values)
{
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];
}
public DhApiMat4f(Mat4f sourceMatrix)
{
this(sourceMatrix.getValuesAsArray());
}
/** Returns the values of this matrix in row major order (AKA rows then columns) */
private float[] getValuesAsArray()
{
return new float[] {
this.m00,
this.m01,
this.m02,
this.m03,
this.m10,
this.m11,
this.m12,
this.m13,
this.m20,
this.m21,
this.m22,
this.m23,
this.m30,
this.m31,
this.m32,
this.m33,
};
}
@Override
public boolean equals(Object obj)
{
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;
}
}
@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";
}
}
@@ -1,57 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.objects.wrappers;
import com.seibel.lod.api.items.interfaces.IDhApiUnsafeWrapper;
import com.seibel.lod.api.items.interfaces.world.IDhApiDimensionTypeWrapper;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.ICoreDhApiUnsafeWrapper;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.world.ICoreDhApiDimensionTypeWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
/**
* @author James Seibel
* @version 2022-9-8
*/
public class DhApiDimensionTypeWrapper implements IDhApiDimensionTypeWrapper
{
private final IDimensionTypeWrapper dimensionTypeWrapper;
public DhApiDimensionTypeWrapper(IDimensionTypeWrapper newDimensionTypeWrapper)
{
this.dimensionTypeWrapper = newDimensionTypeWrapper;
}
@Override
public String getDimensionName() { return this.dimensionTypeWrapper.getDimensionName(); }
@Override
public boolean hasCeiling() { return this.dimensionTypeWrapper.hasCeiling(); }
@Override
public boolean hasSkyLight() { return this.dimensionTypeWrapper.hasSkyLight(); }
@Override
public Object getWrappedMcObject_UNSAFE() { return this.dimensionTypeWrapper.getWrappedMcObject(); }
}
@@ -1,86 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.items.objects.wrappers;
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiLevelType;
import com.seibel.lod.api.items.interfaces.world.IDhApiDimensionTypeWrapper;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IServerLevelWrapper;
/**
* Can be either a Server or Client level.
*
* @author James Seibel
* @version 2022-9-10
*/
public class DhApiLevelWrapper implements IDhApiLevelWrapper
{
private final ILevelWrapper coreLevelWrapper;
private final IDimensionTypeWrapper coreDimensionTypeWrapper;
public DhApiLevelWrapper(ILevelWrapper newLevelWrapper)
{
this.coreLevelWrapper = newLevelWrapper;
this.coreDimensionTypeWrapper = this.coreLevelWrapper.getDimensionType();
}
@Override
public IDhApiDimensionTypeWrapper getDimensionType() { return new DhApiDimensionTypeWrapper(this.coreDimensionTypeWrapper); }
@Override
public EDhApiLevelType getLevelType()
{
if (this.coreLevelWrapper.getClass().isAssignableFrom(IClientLevelWrapper.class))
{
return EDhApiLevelType.CLIENT_LEVEL;
}
else if (this.coreLevelWrapper.getClass().isAssignableFrom(IServerLevelWrapper.class))
{
return EDhApiLevelType.CLIENT_LEVEL;
}
else
{
// shouldn't normally happen, but just in case
return EDhApiLevelType.UNKNOWN;
}
}
@Override
public boolean hasCeiling() { return this.coreLevelWrapper.hasCeiling(); }
@Override
public boolean hasSkyLight() { return this.coreLevelWrapper.hasSkyLight(); }
@Override
public int getHeight() { return this.coreLevelWrapper.getHeight(); }
@Override
public int getMinHeight() { return this.coreLevelWrapper.getMinHeight(); }
@Override
public Object getWrappedMcObject_UNSAFE() { return this.coreLevelWrapper.unwrapLevel(); }
}
@@ -1,9 +1,9 @@
package com.seibel.lod.api.methods.config;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.config.IConverter;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.DefaultConverter;
import com.seibel.lod.core.config.types.ConfigEntry;
import com.seibel.lod.core.interfaces.config.IConfigEntry;
import com.seibel.lod.core.interfaces.config.IConverter;
import com.seibel.lod.core.interfaces.config.converters.DefaultConverter;
/**
* A wrapper used to interface with Distant Horizon's Config.
@@ -18,7 +18,7 @@ import com.seibel.lod.core.config.types.ConfigEntry;
*/
public class DhApiConfig<coreType, apiType> implements IDhApiConfig<apiType>
{
private final ConfigEntry<coreType> configEntry;
private final IConfigEntry<coreType> configEntry;
private final IConverter<coreType, apiType> configConverter;
@@ -30,7 +30,7 @@ public class DhApiConfig<coreType, apiType> implements IDhApiConfig<apiType>
* Uses the default object converter, this requires coreType and apiType to be the same.
*/
@SuppressWarnings("unchecked") // DefaultConverter's cast is safe
public DhApiConfig(ConfigEntry<coreType> newConfigEntry)
public DhApiConfig(IConfigEntry<coreType> newConfigEntry)
{
this.configEntry = newConfigEntry;
this.configConverter = (IConverter<coreType, apiType>) new DefaultConverter<coreType>();
@@ -40,7 +40,7 @@ public class DhApiConfig<coreType, apiType> implements IDhApiConfig<apiType>
* This constructor should only be called internally. <br>
* There is no reason for API users to create this object. <br><br>
*/
public DhApiConfig(ConfigEntry<coreType> newConfigEntry, IConverter<coreType, apiType> newConverter)
public DhApiConfig(IConfigEntry<coreType> newConfigEntry, IConverter<coreType, apiType> newConverter)
{
this.configEntry = newConfigEntry;
this.configConverter = newConverter;
@@ -53,7 +53,7 @@ public class DhApiConfig<coreType, apiType> implements IDhApiConfig<apiType>
public boolean setValue(apiType newValue)
{
if (this.configEntry.allowApiOverride)
if (this.configEntry.getAllowApiOverride())
{
this.configEntry.setApiValue(this.configConverter.convertToCoreType(newValue));
return true;
@@ -64,7 +64,7 @@ public class DhApiConfig<coreType, apiType> implements IDhApiConfig<apiType>
}
}
public boolean getCanBeOverrodeByApi() { return this.configEntry.allowApiOverride; }
public boolean getCanBeOverrodeByApi() { return this.configEntry.getAllowApiOverride(); }
public apiType getDefaultValue() { return this.configConverter.convertToApiType(configEntry.getDefaultValue()); }
public apiType getMaxValue() { return this.configConverter.convertToApiType(this.configEntry.getMax()); }
@@ -1,3 +0,0 @@
The config api package holds objects and methods for getting/setting Distant Horizons' config values.
The configs are split up into: client, server, and both; depending on whether they are relevant to client only use, server only use, or both client and server use.
@@ -1,88 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.methods.config.both;
import com.seibel.lod.api.items.enums.config.EDhApiDistanceGenerationMode;
import com.seibel.lod.api.items.enums.config.EDhApiBlocksToAvoid;
import com.seibel.lod.api.items.enums.config.EDhApiLightGenerationMode;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
import com.seibel.lod.api.methods.config.DhApiConfig;
import com.seibel.lod.core.config.Config.Client.WorldGenerator;
import com.seibel.lod.core.enums.config.EBlocksToAvoid;
import com.seibel.lod.core.enums.config.EDistanceGenerationMode;
import com.seibel.lod.core.enums.config.EGenerationPriority;
import com.seibel.lod.core.enums.config.ELightGenerationMode;
/**
* Distant Horizons' world generation configuration. <br><br>
*
* Note: Fake chunks are NOT saved in Minecraft's vanilla save system.
*
* @author James Seibel
* @version 2022-7-11
*/
public class DhApiWorldGeneration
{
/**
* Defines whether fake chunks will be generated
* outside Minecraft's vanilla render distance.
*/
public static IDhApiConfig<Boolean> getEnableDistantWorldGenerationConfig()
{ return new DhApiConfig<Boolean, Boolean>(WorldGenerator.enableDistantGeneration); }
/** Defines to what level fake chunks will be generated. */
public static IDhApiConfig<EDhApiDistanceGenerationMode> getDistantGeneratorDetailLevelConfig()
{ return new DhApiConfig<EDistanceGenerationMode, EDhApiDistanceGenerationMode>(WorldGenerator.distanceGenerationMode, new GenericEnumConverter<>(EDistanceGenerationMode.class, EDhApiDistanceGenerationMode.class)); }
/** Defines how generated fake chunks will be lit. */
public static IDhApiConfig<EDhApiLightGenerationMode> getLightingModeConfig()
{ return new DhApiConfig<ELightGenerationMode, EDhApiLightGenerationMode>(WorldGenerator.lightGenerationMode, new GenericEnumConverter<>(ELightGenerationMode.class, EDhApiLightGenerationMode.class)); }
/** Defines the order in which fake chunks will be generated. */
public static IDhApiConfig<EDhApiLightGenerationMode> getGenerationPriorityConfig()
{ return new DhApiConfig<EGenerationPriority, EDhApiLightGenerationMode>(WorldGenerator.generationPriority, new GenericEnumConverter<>(EGenerationPriority.class, EDhApiLightGenerationMode.class)); }
/**
* Defines what blocks will be ignored when generating LODs.
*
* TODO if this isn't deprecated before 1.7 it should probably be moved to the graphics tab
* @deprecated this method won't be needed once we transition to an ID based save system <br>
* (vs the color based system we have currently)
*/
@Deprecated
public static IDhApiConfig<EDhApiBlocksToAvoid> getBlocksToAvoidConfig()
{ return new DhApiConfig<EBlocksToAvoid, EDhApiBlocksToAvoid>(WorldGenerator.blocksToAvoid, new GenericEnumConverter<>(EBlocksToAvoid.class, EDhApiBlocksToAvoid.class)); }
/**
* Defines if the color of avoided blocks will color the block below them. <Br>
* (IE: if flowers are avoided should they color the grass below them?)
*
* TODO if this isn't deprecated before 1.7 it should probably be moved to the graphics tab
* @deprecated this method won't be needed once we transition to an ID based save system <br>
* (vs the color based system we have currently)
*/
@Deprecated
public static IDhApiConfig<Boolean> getTintWithAvoidedBlocksConfig()
{ return new DhApiConfig<Boolean, Boolean>(WorldGenerator.tintWithAvoidedBlocks); }
}
@@ -1,52 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.methods.config.client;
import com.seibel.lod.api.items.enums.config.EDhApiGpuUploadMethod;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
import com.seibel.lod.api.methods.config.DhApiConfig;
import com.seibel.lod.core.config.Config.Client.Advanced.Buffers;
import com.seibel.lod.core.enums.config.EGpuUploadMethod;
/**
* Distant Horizons' OpenGL buffer configuration.
*
* @author James Seibel
* @version 2022-7-5
*/
public class DhApiBuffers
{
/** Defines how geometry data is uploaded to the GPU. */
public static IDhApiConfig<EDhApiGpuUploadMethod> getGpuUploadMethodConfig()
{ return new DhApiConfig<EGpuUploadMethod, EDhApiGpuUploadMethod>(Buffers.gpuUploadMethod, new GenericEnumConverter<>(EGpuUploadMethod.class, EDhApiGpuUploadMethod.class)); }
/**
* 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.
*/
public static IDhApiConfig<Integer> getBufferUploadTimeoutPerMegabyteInMillisecondsConfig()
{ return new DhApiConfig<Integer, Integer>(Buffers.gpuUploadPerMegabyteInMilliseconds); }
}
@@ -1,46 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.methods.config.client;
import com.seibel.lod.api.items.enums.config.EDhApiDebugMode;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
import com.seibel.lod.api.methods.config.DhApiConfig;
import com.seibel.lod.core.config.Config.Client.Advanced.Debugging;
import com.seibel.lod.core.enums.rendering.EDebugMode;
/**
* Distant Horizons' debug configuration.
*
* @author James Seibel
* @version 2022-7-5
*/
public class DhApiDebugging
{
/** Can be used to debug the standard fake chunk rendering. */
public static IDhApiConfig<EDhApiDebugMode> getDebugRenderModeConfig()
{ return new DhApiConfig<EDebugMode, EDhApiDebugMode>(Debugging.debugMode, new GenericEnumConverter<>(EDebugMode.class, EDhApiDebugMode.class)); }
/** If enabled debug keybindings can be used. */
public static IDhApiConfig<Boolean> getEnableDebugKeybindingsConfig()
{ return new DhApiConfig<Boolean, Boolean>(Debugging.enableDebugKeybindings); }
}
@@ -1,163 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.methods.config.client;
import com.seibel.lod.api.items.enums.config.*;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.RenderModeEnabledConverter;
import com.seibel.lod.api.methods.config.DhApiConfig;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.ERendererMode;
import com.seibel.lod.core.config.Config.Client.Graphics.Quality;
import com.seibel.lod.core.config.Config.Client.Advanced.Debugging;
import com.seibel.lod.core.config.Config.Client.Graphics.AdvancedGraphics;
/**
* Distant Horizons' graphics/rendering configuration.
*
* @author James Seibel
* @version 2022-7-11
*/
public class DhApiGraphics
{
//========================//
// basic graphic settings //
//========================//
/** The distance is the radius measured in chunks. */
public static IDhApiConfig<Integer> getChunkRenderDistanceConfig()
{ return new DhApiConfig<Integer, Integer>(Quality.lodChunkRenderDistance); }
/**
* Simplified version of {@link DhApiGraphics#getRenderingModeConfig()}
* that only enables/disables the fake chunk rendering. <br><br>
*
* Changing this config also changes {@link DhApiGraphics#getRenderingModeConfig()}'s value.
*/
public static IDhApiConfig<Boolean> getRenderingEnabledConfig()
{ return new DhApiConfig<ERendererMode, Boolean>(Debugging.rendererMode, new RenderModeEnabledConverter()); }
/**
* Can be used to enable/disable fake chunk rendering or enable the debug renderer. <br><br>
*
* The debug renderer is used to confirm rendering is working at and will draw
* a single multicolor rhombus on the screen in skybox space (AKA behind MC's rendering). <br><br>
*
* Changing this config also changes {@link DhApiGraphics#getRenderingEnabledConfig()}'s value.
*/
public static IDhApiConfig<EDhApiRendererMode> getRenderingModeConfig()
{ return new DhApiConfig<ERendererMode, EDhApiRendererMode>(Debugging.rendererMode, new GenericEnumConverter<>(ERendererMode.class, EDhApiRendererMode.class)); }
//==================//
// graphic settings //
//==================//
/** Defines how detailed fake chunks are in the horizontal direction */
public static IDhApiConfig<EDhApiHorizontalResolution> getMaxDetailLevelConfig()
{ return new DhApiConfig<EHorizontalResolution, EDhApiHorizontalResolution>(Quality.drawResolution, new GenericEnumConverter<>(EHorizontalResolution.class, EDhApiHorizontalResolution.class)); }
/** Defines how detailed fake chunks are in the vertical direction */
public static IDhApiConfig<EDhApiVerticalQuality> getVerticalQualityConfig()
{ return new DhApiConfig<EVerticalQuality, EDhApiVerticalQuality>(Quality.verticalQuality, new GenericEnumConverter<>(EVerticalQuality.class, EDhApiVerticalQuality.class)); }
/** Modifies the quadratic function fake chunks use for horizontal quality drop-off. */
public static IDhApiConfig<EDhApiHorizontalQuality> getHorizontalQualityDropoffConfig()
{ return new DhApiConfig<EHorizontalQuality, EDhApiHorizontalQuality>(Quality.horizontalQuality, new GenericEnumConverter<>(EHorizontalQuality.class, EDhApiHorizontalQuality.class)); }
/**
* The same as vanilla Minecraft's biome blending. <br><br>
*
* 0 = blending of 1x1 aka off <br>
* 1 = blending of 3x3 <br>
* 2 = blending of 5x5 <br>
* ... <br>
*/
public static IDhApiConfig<Integer> getBiomeBlendingConfig()
{ return new DhApiConfig<Integer, Integer>(Quality.lodBiomeBlending); }
//===========================//
// advanced graphic settings //
//===========================//
/** If directional culling is disabled fake chunks will be rendered behind the camera. */
public static IDhApiConfig<Boolean> getDisableDirectionalCullingConfig()
{ return new DhApiConfig<Boolean, Boolean>(AdvancedGraphics.disableDirectionalCulling); }
/** Determines how fake chunks are rendered in comparison to vanilla MC's chunks. */
public static IDhApiConfig<EDhApiVanillaOverdraw> getVanillaOverdrawConfig()
{ return new DhApiConfig<EVanillaOverdraw, EDhApiVanillaOverdraw>(AdvancedGraphics.vanillaOverdraw, new GenericEnumConverter<>(EVanillaOverdraw.class, EDhApiVanillaOverdraw.class)); }
/** Modifies how far the vanilla overdraw is rendered in chunks. */
public static IDhApiConfig<Integer> getVanillaOverdrawOffsetConfig()
{ return new DhApiConfig<Integer, Integer>(AdvancedGraphics.overdrawOffset); }
/**
* If enabled the near clip plane is extended to reduce
* overdraw and improve Z-fighting at extreme render distances. <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.
*/
public static IDhApiConfig<Boolean> getUseExtendedNearClipPlaneConfig()
{ return new DhApiConfig<Boolean, Boolean>(AdvancedGraphics.useExtendedNearClipPlane); }
/**
* Modifies how bright fake chunks are. <br>
* This is done when generating the vertex data and is applied before any shaders.
*/
public static IDhApiConfig<Double> getBrightnessMultiplierConfig()
{ return new DhApiConfig<Double, Double>(AdvancedGraphics.brightnessMultiplier); }
/**
* Modifies how saturated fake chunks are. <br>
* This is done when generating the vertex data and is applied before any shaders.
*/
public static IDhApiConfig<Double> getSaturationMultiplierConfig()
{ return new DhApiConfig<Double, Double>(AdvancedGraphics.saturationMultiplier); }
/** Defines if Distant Horizons should attempt to cull fake chunk cave geometry. */
public static IDhApiConfig<Boolean> getCaveCullingEnabledConfig()
{ return new DhApiConfig<Boolean, Boolean>(AdvancedGraphics.enableCaveCulling); }
/** Defines what height cave culling should be used below if enabled. */
public static IDhApiConfig<Integer> getCaveCullingHeightConfig()
{ return new DhApiConfig<Integer, Integer>(AdvancedGraphics.caveCullingHeight); }
/** This ratio is relative to Earth's real world curvature. */
public static IDhApiConfig<Integer> getEarthCurvatureRatioConfig()
{ return new DhApiConfig<Integer, Integer>(AdvancedGraphics.earthCurveRatio); }
/** If enabled vanilla chunk rendering is disabled and only fake chunks are rendered. */
public static IDhApiConfig<Boolean> getEnableLodOnlyModeConfig()
{ return new DhApiConfig<Boolean, Boolean>(Config.Client.Advanced.lodOnlyMode); }
/** Defines how often the geometry should be rebuilt when the player moves. */
public static IDhApiConfig<EDhApiBufferRebuildTimes> getGeometryRebuildFrequencyConfig()
{ return new DhApiConfig<EBufferRebuildTimes, EDhApiBufferRebuildTimes>(Config.Client.Advanced.Buffers.rebuildTimes, new GenericEnumConverter<>(EBufferRebuildTimes.class, EDhApiBufferRebuildTimes.class)); }
}
@@ -1,153 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.methods.config.client;
import com.seibel.lod.api.items.enums.config.*;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
import com.seibel.lod.api.methods.config.DhApiConfig;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.config.Config.Client.Graphics.FogQuality;
/**
* Distant Horizons' fog configuration. <br><br>
*
* Note: unless an option explicitly states that it modifies
* Minecraft's vanilla rendering (like DisableVanillaFog)
* these settings will only affect Distant horizons' fog.
*
* @author James Seibel
* @version 2022-7-11
*/
public class DhApiGraphicsFog
{
//====================//
// basic fog settings //
//====================//
/** Defines at what distance fog is rendered on fake chunks. */
public static IDhApiConfig<EDhApiFogDistance> getFogDistanceConfig()
{ return new DhApiConfig<EFogDistance, EDhApiFogDistance>(FogQuality.fogDistance, new GenericEnumConverter<>(EFogDistance.class, EDhApiFogDistance.class)); }
/** Should be used to enable/disable fog rendering. */
public static IDhApiConfig<EDhApiFogDrawMode> getFogRenderConfig()
{ return new DhApiConfig<EFogDrawMode, EDhApiFogDrawMode>(FogQuality.fogDrawMode, new GenericEnumConverter<>(EFogDrawMode.class, EDhApiFogDrawMode.class)); }
/** Can be used to enable support with mods that change vanilla MC's fog color. */
public static IDhApiConfig<EDhApiFogColorMode> getFogColorConfig()
{ return new DhApiConfig<EFogColorMode, EDhApiFogColorMode>(FogQuality.fogColorMode, new GenericEnumConverter<>(EFogColorMode.class, EDhApiFogColorMode.class)); }
/**
* If enabled attempts to disable vanilla MC's fog on real chunks. <br>
* May not play nice with other fog editing mods.
*/
public static IDhApiConfig<Boolean> getDisableVanillaFogConfig()
{ return new DhApiConfig<Boolean, Boolean>(FogQuality.disableVanillaFog); }
//=======================//
// advanced fog settings //
//=======================//
/**
* Defines where the fog starts as a percent of the
* fake chunks render distance radius. <br>
* Can be greater than the fog end distance to invert the fog direction. <br> <br>
*
* 0.0 = fog starts at the camera <br>
* 1.0 = fog starts at the edge of the fake chunk render distance <br>
*/
public static IDhApiConfig<Double> getFogStartDistanceConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.farFogStart); }
/**
* Defines where the fog ends as a percent of the radius
* of the fake chunks render distance. <br>
* Can be less than the fog start distance to invert the fog direction. <br> <br>
*
* 0.0 = fog ends at the camera <br>
* 1.0 = fog ends at the edge of the fake chunk render distance <br>
*/
public static IDhApiConfig<Double> getFogEndDistanceConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.farFogEnd); }
/** Defines how opaque the fog is at its thinnest point. */
public static IDhApiConfig<Double> getFogMinThicknessConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.farFogMin); }
/** Defines how opaque the fog is at its thickest point. */
public static IDhApiConfig<Double> getFogMaxThicknessConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.farFogMax); }
/** Defines how the fog changes in thickness. */
public static IDhApiConfig<EDhApiFogFalloff> getFogFalloffConfig()
{ return new DhApiConfig<EFogFalloff, EDhApiFogFalloff>(FogQuality.AdvancedFog.farFogType, new GenericEnumConverter<>(EFogFalloff.class, EDhApiFogFalloff.class)); }
/** Defines the fog density. */
public static IDhApiConfig<Double> getFogDensityConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.farFogDensity); }
//=====================//
// height fog settings //
//=====================//
/** Defines how the height fog mixes. */
public static IDhApiConfig<EDhApiHeightFogMixMode> getHeightFogMixModeConfig()
{ return new DhApiConfig<EHeightFogMixMode, EDhApiHeightFogMixMode>(FogQuality.AdvancedFog.HeightFog.heightFogMixMode, new GenericEnumConverter<>(EHeightFogMixMode.class, EDhApiHeightFogMixMode.class)); }
/** Defines how the height fog is drawn relative to the camera or world. */
public static IDhApiConfig<EDhApiHeightFogMode> getHeightFogModeConfig()
{ return new DhApiConfig<EHeightFogMode, EDhApiHeightFogMode>(FogQuality.AdvancedFog.HeightFog.heightFogMode, new GenericEnumConverter<>(EHeightFogMode.class, EDhApiHeightFogMode.class)); }
/**
* Defines the height fog's base height if {@link DhApiGraphicsFog#getHeightFogModeConfig()}
* is set to use a specific height.
*/
public static IDhApiConfig<Double> getHeightFogBaseHeightConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.HeightFog.heightFogHeight); }
/** Defines the height fog's starting height as a percent of the world height. */
public static IDhApiConfig<Double> getHeightFogStartingHeightPercentConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.HeightFog.heightFogStart); }
/** Defines the height fog's ending height as a percent of the world height. */
public static IDhApiConfig<Double> getHeightFogEndingHeightPercentConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.HeightFog.heightFogEnd); }
/** Defines how opaque the height fog is at its thinnest point. */
public static IDhApiConfig<Double> getHeightFogMinThicknessConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.HeightFog.heightFogMin); }
/** Defines how opaque the height fog is at its thickest point. */
public static IDhApiConfig<Double> getHeightFogMaxThicknessConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.HeightFog.heightFogMax); }
/** Defines how the height fog changes in thickness. */
public static IDhApiConfig<EDhApiFogFalloff> getHeightFogFalloffConfig()
{ return new DhApiConfig<EFogFalloff, EDhApiFogFalloff>(FogQuality.AdvancedFog.HeightFog.heightFogType, new GenericEnumConverter<>(EFogFalloff.class, EDhApiFogFalloff.class)); }
/** Defines the height fog's density. */
public static IDhApiConfig<Double> getHeightFogDensityConfig()
{ return new DhApiConfig<Double, Double>(FogQuality.AdvancedFog.HeightFog.heightFogDensity); }
}
@@ -1,58 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.methods.config.client;
import com.seibel.lod.api.items.enums.config.EDhApiServerFolderNameMode;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
import com.seibel.lod.api.methods.config.DhApiConfig;
import com.seibel.lod.core.config.Config.Client.Multiplayer;
import com.seibel.lod.core.enums.config.EServerFolderNameMode;
/**
* Distant Horizons' client-side multiplayer configuration.
*
* @author James Seibel
* @version 2022-7-5
*/
public class DhApiMultiplayer
{
/**
* Defines how multiplayer server folders are named. <br>
* Note: Changing this while connected to a multiplayer world will cause undefined behavior!
*/
public static IDhApiConfig<EDhApiServerFolderNameMode> getFolderSavingModeConfig()
{ return new DhApiConfig<EServerFolderNameMode, EDhApiServerFolderNameMode>(Multiplayer.serverFolderNameMode, new GenericEnumConverter<>(EServerFolderNameMode.class, EDhApiServerFolderNameMode.class)); }
/**
* Defines the necessary similarity (as a percent) that two potential levels
* need in order to be considered the same. <br> <br>
*
* Setting this to zero causes every level of a specific dimension type to be consider
* the same level. <br>
* Setting this to a non-zero value allows for usage in servers that user Multiverse
* or similar mods.
*/
public static IDhApiConfig<Double> getMultiverseSimilarityRequirementConfig()
{ return new DhApiConfig<Double, Double>(Multiplayer.multiDimensionRequiredSimilarity); }
}
@@ -1,67 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.api.methods.config.client;
import com.seibel.lod.api.items.interfaces.config.IDhApiConfig;
import com.seibel.lod.api.methods.config.DhApiConfig;
import com.seibel.lod.core.config.Config.Client.Advanced.Threading;
/**
* Distant Horizons' threading configuration.
*
* @author James Seibel
* @version 2022-7-5
*/
public class DhApiThreading
{
/**
* Defines how many world generator threads are used to generate
* terrain outside Minecraf's vanilla render distance. <br>
* <br>
* If the number of threads is less than 1 it will be treated as a percentage
* representing how often the single thread will actively generate terrain. <br> <br>
*
* 0.1 = 1 thread active 10% of the time <br>
* 0.5 = 1 thread active 50% of the time <br>
* 1.0 = 1 thread active 100% of the time <br>
* 1.5 = 2 threads active 100% of the time (partial values are rounded up) <br>
* 2.0 = 2 threads active 100% of the time <br>
*
* @deprecated this (and the related config) should be replaced with an int
* count of threads and then a double percent active config.
*/
@Deprecated
public static IDhApiConfig<Double> getWorldGeneratorThreadConfig()
{ return new DhApiConfig<Double, Double>(Threading.numberOfWorldGenerationThreads); }
// TODO the above should be replaced with these
// public static IDhApiConfig<Integer> getWorldGeneratorThreadConfig()
// { return new DhApiConfig<>(Threading.numberOfWorldGenerationThreads); }
// public static IDhApiConfig<Double> getWorldGeneratorThreadActivePercentConfig()
// { return new DhApiConfig<>(Threading.ToBeDetermined); }
/** Defines how many buffer (GPU Terrain data) builder threads are used. */
public static IDhApiConfig<Integer> getBufferBuilderThreadConfig()
{ return new DhApiConfig<Integer, Integer>(Threading.numberOfBufferBuilderThreads); }
}
@@ -1,8 +1,7 @@
package com.seibel.lod.api.methods.events;
import com.seibel.lod.api.items.objects.DhApiResult;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.events.ICoreDhApiEvent;
import com.seibel.lod.core.dependencyInjection.DhApiEventInjector;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
/**
* Handles adding/removing event handlers.
@@ -18,11 +17,11 @@ public class DhApiEventRegister
* If multiple of the same eventHandler are added DhApiResult will return
* the name of the already added handler and success = false.
*/
public static DhApiResult on(Class<? extends ICoreDhApiEvent> eventInterface, ICoreDhApiEvent eventHandlerImplementation)
public static DhApiResult on(Class<? extends IDhApiEvent> eventInterface, IDhApiEvent eventHandlerImplementation)
{
try
{
DhApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
// DhApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
return DhApiResult.createSuccess();
}
catch (IllegalStateException e)
@@ -36,16 +35,16 @@ public class DhApiEventRegister
* If no eventHandler of the given class has been registered the result will return
* success = false.
*/
public static DhApiResult off(Class<? extends ICoreDhApiEvent> eventInterface, Class<ICoreDhApiEvent> eventHandlerClass)
public static DhApiResult off(Class<? extends IDhApiEvent> eventInterface, Class<IDhApiEvent> eventHandlerClass)
{
if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
{
return DhApiResult.createSuccess();
}
else
{
// if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
// {
// return DhApiResult.createSuccess();
// }
// else
// {
return DhApiResult.createFail("No event handler [" + eventHandlerClass.getSimpleName() + "] was bound for the event [" + eventInterface.getSimpleName() + "].");
}
// }
}
}
@@ -1,15 +1,13 @@
package com.seibel.lod.api.methods.events.abstractEvents;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiAfterDhInitEvent;
/**
* @author James Seibel
* @version 2022-9-6
*/
public abstract class DhApiAfterDhInitEvent
extends CoreDhApiAfterDhInitEvent
implements IDhApiEvent<Void, Void>
implements IDhApiEvent<Void>
{
/** Fired after Distant Horizons finishes its initial setup on Minecraft startup. */
public abstract void afterDistantHorizonsInit();
@@ -2,15 +2,14 @@ package com.seibel.lod.api.methods.events.abstractEvents;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiAfterRenderEvent;
import com.seibel.lod.core.util.math.Mat4f;
/**
* @author James Seibel
* @version 2022-9-6
*/
public abstract class DhApiAfterRenderEvent
extends CoreDhApiAfterRenderEvent
implements IDhApiEvent<DhApiAfterRenderEvent.EventParam, CoreDhApiAfterRenderEvent.CoreEventParam>
implements IDhApiEvent<DhApiAfterRenderEvent.EventParam>
{
/** Fired after Distant Horizons finishes rendering fake chunks. */
public abstract void afterRender(EventParam input);
@@ -21,9 +20,9 @@ public abstract class DhApiAfterRenderEvent
//=========================//
@Override
public final boolean fireEvent(CoreEventParam input)
public final boolean fireEvent(EventParam input)
{
afterRender(new EventParam(input));
afterRender(input);
return false;
}
@@ -37,7 +36,10 @@ public abstract class DhApiAfterRenderEvent
public static class EventParam extends DhApiRenderParam
{
public EventParam(CoreEventParam dhApiRenderParam) { super(dhApiRenderParam); }
public EventParam(DhApiRenderParam parent)
{
super(parent.mcProjectionMatrix, parent.mcModelViewMatrix, parent.dhProjectionMatrix, parent.dhModelViewMatrix, parent.partialTicks);
}
}
}
@@ -3,15 +3,13 @@ package com.seibel.lod.api.methods.events.abstractEvents;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiBeforeDhInitEvent;
/**
* @author James Seibel
* @version 2022-9-6
*/
public abstract class DhApiBeforeDhInitEvent
extends CoreDhApiBeforeDhInitEvent
implements IDhApiEvent<Void, Void>
implements IDhApiEvent<Void>
{
/** Fired before Distant Horizons starts its initial setup on Minecraft startup. */
public abstract void beforeDistantHorizonsInit();
@@ -2,15 +2,14 @@ package com.seibel.lod.api.methods.events.abstractEvents;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiBeforeRenderEvent;
import com.seibel.lod.core.util.math.Mat4f;
/**
* @author James Seibel
* @version 2022-9-6
*/
public abstract class DhApiBeforeRenderEvent
extends CoreDhApiBeforeRenderEvent
implements IDhApiEvent<DhApiBeforeRenderEvent.EventParam, CoreDhApiBeforeRenderEvent.CoreEventParam>
implements IDhApiEvent<DhApiBeforeRenderEvent.EventParam>
{
/**
* Fired before Distant Horizons renders fake chunks.
@@ -25,7 +24,7 @@ public abstract class DhApiBeforeRenderEvent
//=========================//
@Override
public final boolean fireEvent(CoreEventParam input) { return beforeRender(new EventParam(input)); }
public final boolean fireEvent(EventParam input) { return beforeRender(input); }
@Override
public final boolean getCancelable() { return true; }
@@ -37,7 +36,10 @@ public abstract class DhApiBeforeRenderEvent
public static class EventParam extends DhApiRenderParam
{
public EventParam(CoreEventParam dhApiRenderParam) { super(dhApiRenderParam); }
public EventParam(DhApiRenderParam parent)
{
super(parent.mcProjectionMatrix, parent.mcModelViewMatrix, parent.dhProjectionMatrix, parent.dhModelViewMatrix, parent.partialTicks);
}
}
}
@@ -1,18 +1,14 @@
package com.seibel.lod.api.methods.events.abstractEvents;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.api.items.objects.wrappers.DhApiLevelWrapper;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiLevelLoadEvent;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
/**
* @author James Seibel
* @version 2022-9-10
*/
public abstract class DhApiLevelLoadEvent
extends CoreDhApiLevelLoadEvent
implements IDhApiEvent<DhApiLevelLoadEvent.EventParam, CoreDhApiLevelLoadEvent.CoreEventParam>
implements IDhApiEvent<DhApiLevelLoadEvent.EventParam>
{
/** Fired after Distant Horizons loads a new level. */
public abstract void onLevelLoad(EventParam input);
@@ -23,9 +19,9 @@ public abstract class DhApiLevelLoadEvent
//=========================//
@Override
public final boolean fireEvent(CoreEventParam input)
public final boolean fireEvent(EventParam input)
{
onLevelLoad(new EventParam(input.levelWrapper));
onLevelLoad(input);
return false;
}
@@ -43,7 +39,7 @@ public abstract class DhApiLevelLoadEvent
public final IDhApiLevelWrapper levelWrapper;
public EventParam(ILevelWrapper newLevelWrapper) { this.levelWrapper = new DhApiLevelWrapper(newLevelWrapper); }
public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
}
}
@@ -1,18 +1,14 @@
package com.seibel.lod.api.methods.events.abstractEvents;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.api.items.objects.wrappers.DhApiLevelWrapper;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiLevelSaveEvent;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
/**
* @author James Seibel
* @version 2022-9-10
*/
public abstract class DhApiLevelSaveEvent
extends CoreDhApiLevelSaveEvent
implements IDhApiEvent<DhApiLevelSaveEvent.EventParam, CoreDhApiLevelSaveEvent.CoreEventParam>
implements IDhApiEvent<DhApiLevelSaveEvent.EventParam>
{
/** Fired after Distant Horizons saves LOD data for the server. */
public abstract void onLevelSave(EventParam input);
@@ -23,9 +19,9 @@ public abstract class DhApiLevelSaveEvent
//=========================//
@Override
public final boolean fireEvent(CoreDhApiLevelSaveEvent.CoreEventParam input)
public final boolean fireEvent(EventParam input)
{
onLevelSave(new EventParam(input.levelWrapper));
onLevelSave(input);
return false;
}
@@ -43,7 +39,7 @@ public abstract class DhApiLevelSaveEvent
public final IDhApiLevelWrapper levelWrapper;
public EventParam(ILevelWrapper newLevelWrapper) { this.levelWrapper = new DhApiLevelWrapper(newLevelWrapper); }
public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
}
}
@@ -1,18 +1,14 @@
package com.seibel.lod.api.methods.events.abstractEvents;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.api.items.objects.wrappers.DhApiLevelWrapper;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiLevelUnloadEvent;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
/**
* @author James Seibel
* @version 2022-9-10
*/
public abstract class DhApiLevelUnloadEvent
extends CoreDhApiLevelUnloadEvent
implements IDhApiEvent<DhApiLevelUnloadEvent.EventParam, CoreDhApiLevelUnloadEvent.CoreEventParam>
public abstract class DhApiLevelUnloadEvent
implements IDhApiEvent<DhApiLevelUnloadEvent.EventParam>
{
/** Fired before Distant Horizons unloads a level. */
public abstract void onLevelUnload(EventParam input);
@@ -23,9 +19,9 @@ public abstract class DhApiLevelUnloadEvent
//=========================//
@Override
public final boolean fireEvent(CoreDhApiLevelUnloadEvent.CoreEventParam input)
public final boolean fireEvent(EventParam input)
{
onLevelUnload(new EventParam(input.levelWrapper));
onLevelUnload(input);
return false;
}
@@ -43,7 +39,7 @@ public abstract class DhApiLevelUnloadEvent
public final IDhApiLevelWrapper levelWrapper;
public EventParam(ILevelWrapper newLevelWrapper) { this.levelWrapper = new DhApiLevelWrapper(newLevelWrapper); }
public EventParam(IDhApiLevelWrapper newLevelWrapper) { this.levelWrapper = newLevelWrapper; }
}
}
@@ -1,22 +1,22 @@
package com.seibel.lod.api.methods.events.interfaces;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.events.ICoreDhApiEvent;
import com.seibel.lod.core.dependencyInjection.IBindable;
/**
* A combination of all interfaces required by all
* DH Api events.
*
* @param <ApiInputType> This is the datatype that will be passed into the
* event handler's method.
* @param <CoreInputType> This is the datatype that will be passed in from Core
* when the event is fired.
* @param <T> This is the datatype that will be passed into the event handler's method.
*
* @author James Seibel
* @version 2022-9-6
*/
public interface IDhApiEvent<ApiInputType, CoreInputType> extends ICoreDhApiEvent<CoreInputType>, IBindable
public interface IDhApiEvent<T> extends IBindable
{
//==========//
// external //
//==========//
/**
* Returns if the event should be automatically unbound
* after firing. <br>
@@ -24,7 +24,25 @@ public interface IDhApiEvent<ApiInputType, CoreInputType> extends ICoreDhApiEven
*
* Defaults to False (the event will not be removed after firing).
*/
@Override
default boolean removeAfterFiring() { return false; };
//==========//
// internal //
//==========//
/** Returns true if the event can be canceled. */
boolean getCancelable();
/**
* Called internally by Distant Horizons when the event happens.
* This method shouldn't directly be overridden and
* should call a more specific method instead.
*
* @param input the parameter object passed in from the event source. Can be null.
* @return whether the event should be canceled or not.
* A canceled event will still fire the other event handlers that are queued.
*/
boolean fireEvent(T input);
}
@@ -1,7 +1,6 @@
package com.seibel.lod.api.methods.events.sharedParameterObjects;
import com.seibel.lod.api.items.objects.math.DhApiMat4f;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.sharedParameterObjects.CoreDhApiRenderParam;
import com.seibel.lod.core.util.math.Mat4f;
/**
* Parameter passed into Render events.
@@ -12,29 +11,32 @@ import com.seibel.lod.core.api.external.coreImplementations.objects.events.share
public class DhApiRenderParam
{
/** 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;
/** Indicates how far into this tick the frame is. */
public final float partialTicks;
public DhApiRenderParam(CoreDhApiRenderParam param)
public DhApiRenderParam(
Mat4f newMcProjectionMatrix, Mat4f newMcModelViewMatrix,
Mat4f newDhProjectionMatrix, Mat4f newDhModelViewMatrix,
float newPartialTicks)
{
this.mcProjectionMatrix = new DhApiMat4f(param.mcProjectionMatrix);
this.mcModelViewMatrix = new DhApiMat4f(param.mcModelViewMatrix);
this.mcProjectionMatrix = newMcProjectionMatrix;
this.mcModelViewMatrix = newMcModelViewMatrix;
this.dhProjectionMatrix = new DhApiMat4f(param.dhProjectionMatrix);
this.dhModelViewMatrix = new DhApiMat4f(param.dhModelViewMatrix);
this.dhProjectionMatrix = newDhProjectionMatrix;
this.dhModelViewMatrix = newDhModelViewMatrix;
this.partialTicks = param.partialTicks;
this.partialTicks = newPartialTicks;
}
}
@@ -2,8 +2,6 @@ package com.seibel.lod.api.override;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.api.items.objects.DhApiResult;
import com.seibel.lod.core.api.external.coreImplementations.interfaces.override.worldGenerator.ICoreDhApiWorldGenerator;
import com.seibel.lod.core.dependencyInjection.WorldGeneratorInjector;
/**
* Handles adding world generator overrides.
@@ -21,18 +19,18 @@ public class DhApiWorldGeneratorOverrideRegister
* If another world generator has already been registered, DhApiResult will return
* the name of the previously registered generator and success = false.
*/
public static DhApiResult registerWorldGeneratorOverride(ICoreDhApiWorldGenerator worldGenerator)
{
try
{
WorldGeneratorInjector.INSTANCE.bind(worldGenerator);
return DhApiResult.createSuccess();
}
catch (Exception e)
{
return DhApiResult.createFail(e.getMessage());
}
}
// public static DhApiResult registerWorldGeneratorOverride(ICoreDhApiWorldGenerator worldGenerator)
// {
// try
// {
// WorldGeneratorInjector.INSTANCE.bind(worldGenerator);
// return DhApiResult.createSuccess();
// }
// catch (Exception e)
// {
// return DhApiResult.createFail(e.getMessage());
// }
// }
/**
* Registers the given world generator for the given level. <Br> <Br>
@@ -41,18 +39,18 @@ public class DhApiWorldGeneratorOverrideRegister
* If another world generator has already been registered, DhApiResult will return
* the name of the previously registered generator and success = false.
*/
public static DhApiResult registerWorldGeneratorOverride(IDhApiLevelWrapper levelWrapper, ICoreDhApiWorldGenerator worldGenerator)
{
try
{
// public static DhApiResult registerWorldGeneratorOverride(IDhApiLevelWrapper levelWrapper, ICoreDhApiWorldGenerator worldGenerator)
// {
// try
// {
// WorldGeneratorInjector.INSTANCE.bind(levelWrapper, worldGenerator);
return DhApiResult.createSuccess();
}
catch (Exception e)
{
return DhApiResult.createFail(e.getMessage());
}
}
// return DhApiResult.createSuccess();
// }
// catch (Exception e)
// {
// return DhApiResult.createFail(e.getMessage());
// }
// }
}
@@ -0,0 +1,55 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core;
import java.util.Locale;
/**
* This file is similar to mcmod.info
* <br>
* If you are looking at this mod's source code and don't
* know where to start.
* Go to the api/lod package (folder) and take a look at the ClientApi.java file,
* Pretty much all of the mod stems from there.
*
* @author James Seibel
* @author Ran
* @version 2022-4-27
*/
public final class ModInfo
{
public static final String ID = "lod";
/** The internal protocol version used for networking */
public static final int PROTOCOL_VERSION = 1;
/** The internal mod name */
public static final String NAME = "DistantHorizons";
/** Human readable version of NAME */
public static final String READABLE_NAME = "Distant Horizons";
public static final String VERSION = "1.7.0a-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 = 0;
/** This version should be updated whenever new methods are added to the DH API */
public static final int API_MINOR_VERSION = 0;
}
@@ -16,39 +16,35 @@
* 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.lod.api.items.enums.config;
package com.seibel.lod.core.dependencyInjection;
/**
* NEVER, <br>
* DYNAMIC, <br>
* ALWAYS <br> <br>
*
* This represents how far the LODs should overlap with
* the vanilla Minecraft terrain.
* Necessary for all singletons that can be dependency injected.
*
* @author James Seibel
* @version 2022-6-30
* @version 2022-7-16
*/
public enum EDhApiVanillaOverdraw
public interface IBindable
{
// Reminder:
// when adding items up the API minor version
// when removing items up the API major version
/**
* Finish initializing this object. <br> <br>
*
* Generally this should just be used for getting other objects through
* dependency injection and is specifically designed to allow
* for circular references. <br><br>
*
* If no circular dependencies are required this method
* doesn't have to be implemented.
*/
public default void finishDelayedSetup() { }
/**
* Don't draw LODs where a minecraft chunk could be.
* Use Overdraw Offset to tweak the border thickness.
* Returns if this dependency has been setup yet. <Br> <Br>
*
* If this object doesn't require a delayed setup, this
* method doesn't have to be implemented and should always return true.
*/
NEVER,
public default boolean getDelayedSetupComplete() { return true; }
/**
* Draw LODs over the farther minecraft chunks.
* Dynamically decides the border thickness
*/
DYNAMIC,
/** Draw LODs over all minecraft chunks. */
ALWAYS,
}
}
@@ -0,0 +1,75 @@
package com.seibel.lod.core.dependencyInjection;
import java.util.ArrayList;
public interface IDependencyInjector<BindableType extends IBindable>
{
/**
* Links the given implementation object to an interface, so it can be referenced later.
*
* @param dependencyInterface The interface (or parent class) the implementation object should implement.
* @param dependencyImplementation An object that implements the dependencyInterface interface.
* @throws IllegalStateException if the interface has already been bound and duplicates aren't allowed
* @throws IllegalArgumentException if the implementation object doesn't implement the interface
*/
void bind(Class<? extends BindableType> dependencyInterface, BindableType dependencyImplementation) throws IllegalStateException, IllegalArgumentException;
/**
* Checks if classToTest (or one of its ancestors)
* implements the given interface.
*/
boolean checkIfClassImplements(Class<?> classToTest, Class<?> interfaceToLookFor);
/** Checks if classToTest extends the given class. */
boolean checkIfClassExtends(Class<?> classToTest, Class<?> extensionToLookFor);
/**
* This does not return incomplete dependencies. <Br>
* See {@link #get(Class, boolean) get(Class, boolean)} for full documentation.
*
* @see #get(Class, boolean)
*/
@SuppressWarnings("unchecked")
<T extends BindableType> T get(Class<T> interfaceClass) throws ClassCastException;
/**
* Returns all dependencies of type T that have been bound. <br>
* Returns an empty list if no dependencies have been bound.
*
* @param <T> class of the dependency
* (inferred from the objectClass parameter)
* @param interfaceClass Interface of the dependency
* @return the dependency of type T
* @throws ClassCastException If the dependency isn't able to be cast to type T.
* (this shouldn't normally happen, unless the bound object changed somehow)
*/
<T extends BindableType> ArrayList<T> getAll(Class<T> interfaceClass) throws ClassCastException;
/**
* Returns a dependency of type T if one has been bound. <br>
* Returns null if a dependency hasn't been bound. <br> <br>
*
* If the handler's {@link #allowDuplicateBindings} is true this returns the first bound dependency.
*
* @param <T> class of the dependency
* (inferred from the interfaceClass parameter)
* @param interfaceClass Interface of the dependency
* @param allowIncompleteDependencies If true this method will also return dependencies that haven't completed their delayed setup.
* @return the dependency of type T
* @throws ClassCastException If the dependency isn't able to be cast to type T.
* (this shouldn't normally happen, unless the bound object changed somehow)
*/
@SuppressWarnings("unchecked")
<T extends BindableType> T get(Class<T> interfaceClass, boolean allowIncompleteDependencies) throws ClassCastException;
/** Removes all bound dependencies. */
public void clear();
/** Runs delayed setup for any dependencies that require it. */
void runDelayedSetup();
}
@@ -0,0 +1,56 @@
package com.seibel.lod.core.dependencyInjection;
import com.seibel.lod.api.items.interfaces.override.IDhApiOverrideable;
public interface IOverrideInjector<BindableType extends IBindable>
{
/**
* All core overrides should have this priority. <Br>
* Should be lower than MIN_OVERRIDE_PRIORITY.
*/
public static final int CORE_PRIORITY = -1;
/**
* The lowest priority non-core overrides can have.
* Should be higher than CORE_PRIORITY.
*/
public static final int MIN_NON_CORE_OVERRIDE_PRIORITY = 0;
/** The priority given to overrides that don't explicitly define a priority. */
public static final int DEFAULT_NON_CORE_OVERRIDE_PRIORITY = 10;
/**
* See {@link IDependencyInjector#bind(Class, IBindable) bind(Class, IBindable)} for full documentation.
*
* @throws IllegalArgumentException if a non-Distant Horizons Override with the priority CORE is passed in or a invalid priority value.
* @throws IllegalStateException if another override with the given priority already has been bound.
* @see IDependencyInjector#bind(Class, IBindable)
*/
void bind(Class<? extends IDhApiOverrideable> dependencyInterface, IDhApiOverrideable dependencyImplementation) throws IllegalStateException, IllegalArgumentException;
/**
* Returns the bound dependency with the highest priority. <br>
* See {@link IDependencyInjector#get(Class, boolean) get(Class, boolean)} for full documentation.
*
* @see IDependencyInjector#get(Class, boolean)
*/
<T extends IDhApiOverrideable> T get(Class<T> interfaceClass) throws ClassCastException;
/**
* Returns a dependency of type T with the specified priority if one has been bound. <br>
* If there is a dependency, but it was bound with a different priority this will return null. <br> <br>
*
* See {@link IDependencyInjector#get(Class, boolean) get(Class, boolean)} for more documentation.
*
* @see IDependencyInjector#get(Class, boolean)
*/
<T extends IDhApiOverrideable> T get(Class<T> interfaceClass, int priority) throws ClassCastException;
/** Removes all bound overrides. */
void clear();
}
@@ -0,0 +1,59 @@
package com.seibel.lod.core.interfaces.config;
/**
* Use for making the config variables
*
* @author coolGi
* @version 2022-5-26
*/
public interface IConfigEntry<T>
{
/** Gets the default value of the option */
T getDefaultValue();
void setApiValue(T newApiValue);
T getApiValue();
/** Returns true if this config can be set via the API. */
boolean getAllowApiOverride();
void set(T newValue);
T get();
T getTrueValue();
/** Sets the value without saving */
void setWithoutSaving(T newValue);
/** Gets the min value */
T getMin();
/** Sets the min value */
void setMin(T newMin);
/** Gets the max value */
T getMax();
/** Sets the max value */
void setMax(T newMax);
/** Sets the min and max in 1 setter */
void setMinMax(T newMin, T newMax);
/** Gets the comment */
String getComment();
/** Sets the comment */
void setComment(String newComment);
/**
* Checks if the option is valid
*
* 0 == valid
* 1 == number too high
* -1 == number too low
*/
byte isValid();
/** Checks if a value is valid */
byte isValid(T value);
/** Is the value of this equal to another */
boolean equals(IConfigEntry<?> obj);
}
@@ -0,0 +1,20 @@
package com.seibel.lod.core.interfaces.config;
/**
* Interface used for converting Core and API objects.
*
* @param <CoreType> The type used by DH Core (not visible to the API user)
* @param <ApiType> The type used by DH API (not used by Core)
* @author James Seibel
* @version 2022-7-16
*/
public interface IConverter<CoreType, ApiType>
{
CoreType convertToCoreType(ApiType apiObject);
ApiType convertToApiType(CoreType coreObject);
}
@@ -0,0 +1,26 @@
package com.seibel.lod.core.interfaces.config.converters;
import com.seibel.lod.core.interfaces.config.IConverter;
/**
* Returns the object passed in, doesn't do any conversion. <br>
* Helpful as the default converter in some cases.
*
* @author James Seibel
* @version 2022-6-30
*/
public class DefaultConverter<T> implements IConverter<T, T>
{
@Override
public T convertToCoreType(T apiObject)
{
return apiObject;
}
@Override
public T convertToApiType(T coreObject)
{
return coreObject;
}
}
@@ -0,0 +1,25 @@
package com.seibel.lod.core.interfaces.config.converters;
import com.seibel.lod.api.items.enums.rendering.ERendererMode;
import com.seibel.lod.core.interfaces.config.IConverter;
/**
* Used for simplifying the fake chunk rendering on/off setting.
*
* @author James Seibel
* @version 2022-6-30
*/
public class RenderModeEnabledConverter implements IConverter<ERendererMode, Boolean>
{
@Override public ERendererMode convertToCoreType(Boolean renderingEnabled)
{
return renderingEnabled ? ERendererMode.DEFAULT : ERendererMode.DISABLED;
}
@Override public Boolean convertToApiType(ERendererMode renderingMode)
{
return renderingMode == ERendererMode.DEFAULT;
}
}
@@ -0,0 +1,64 @@
package com.seibel.lod.core.util;
public class MathUtil
{
/**
* Clamps the given value between the min and max values.
* May behave strangely if min > max.
*/
public static int clamp(int min, int value, int max)
{
return Math.min(max, Math.max(value, min));
}
/**
* Clamps the given value between the min and max values.
* May behave strangely if min > max.
*/
public static float clamp(float min, float value, float max)
{
return Math.min(max, Math.max(value, min));
}
/**
* Clamps the given value between the min and max values.
* May behave strangely if min > max.
*/
public static double clamp(double min, double value, double max)
{
return Math.min(max, Math.max(value, min));
}
/**
* Like Math.floorDiv, but reverse in that it is a ceilDiv
*/
public static int ceilDiv(int value, int divider) {
return -Math.floorDiv(-value, divider);
}
// Why is this not in the standard library?! Come on Java!
public static byte min(byte a, byte b) {
return a < b ? a : b;
}
public static byte max(byte a, byte b) {
return a > b ? a : b;
}
/** This is copied from Minecraft's MathHelper class */
public static float fastInvSqrt(float numb)
{
float half = 0.5F * numb;
int i = Float.floatToIntBits(numb);
i = 1597463007 - (i >> 1);
numb = Float.intBitsToFloat(i);
return numb * (1.5F - half * numb * numb);
}
public static float pow2(float x) {return x*x;}
public static double pow2(double x) {return x*x;}
public static int pow2(int x) {return x*x;}
public static long pow2(long x) {return x*x;}
}
@@ -0,0 +1,581 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.util.math;
import java.nio.FloatBuffer;
/**
* An (almost) exact copy of Minecraft's 1.16.5
* implementation of a 4x4 float matrix.
*
* @author James Seibel
* @version 11-11-2021
*/
public class Mat4f
{
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()
{
}
public Mat4f(Mat4f sourceMatrix)
{
this.m00 = sourceMatrix.m00;
this.m01 = sourceMatrix.m01;
this.m02 = sourceMatrix.m02;
this.m03 = sourceMatrix.m03;
this.m10 = sourceMatrix.m10;
this.m11 = sourceMatrix.m11;
this.m12 = sourceMatrix.m12;
this.m13 = sourceMatrix.m13;
this.m20 = sourceMatrix.m20;
this.m21 = sourceMatrix.m21;
this.m22 = sourceMatrix.m22;
this.m23 = sourceMatrix.m23;
this.m30 = sourceMatrix.m30;
this.m31 = sourceMatrix.m31;
this.m32 = sourceMatrix.m32;
this.m33 = sourceMatrix.m33;
}
/* 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";
}
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);
}
private static int bufferIndex(int xIndex, int zIndex)
{
return (zIndex * 4) + xIndex;
}
public void setIdentity()
{
this.m00 = 1.0F;
this.m01 = 0.0F;
this.m02 = 0.0F;
this.m03 = 0.0F;
this.m10 = 0.0F;
this.m11 = 1.0F;
this.m12 = 0.0F;
this.m13 = 0.0F;
this.m20 = 0.0F;
this.m21 = 0.0F;
this.m22 = 1.0F;
this.m23 = 0.0F;
this.m30 = 0.0F;
this.m31 = 0.0F;
this.m32 = 0.0F;
this.m33 = 1.0F;
}
/** adjudicate and determinate */
public float adjudicateAndDet()
{
float f = this.m00 * this.m11 - this.m01 * this.m10;
float f1 = this.m00 * this.m12 - this.m02 * this.m10;
float f2 = this.m00 * this.m13 - this.m03 * this.m10;
float f3 = this.m01 * this.m12 - this.m02 * this.m11;
float f4 = this.m01 * this.m13 - this.m03 * this.m11;
float f5 = this.m02 * this.m13 - this.m03 * this.m12;
float f6 = this.m20 * this.m31 - this.m21 * this.m30;
float f7 = this.m20 * this.m32 - this.m22 * this.m30;
float f8 = this.m20 * this.m33 - this.m23 * this.m30;
float f9 = this.m21 * this.m32 - this.m22 * this.m31;
float f10 = this.m21 * this.m33 - this.m23 * this.m31;
float f11 = this.m22 * this.m33 - this.m23 * this.m32;
float f12 = this.m11 * f11 - this.m12 * f10 + this.m13 * f9;
float f13 = -this.m10 * f11 + this.m12 * f8 - this.m13 * f7;
float f14 = this.m10 * f10 - this.m11 * f8 + this.m13 * f6;
float f15 = -this.m10 * f9 + this.m11 * f7 - this.m12 * f6;
float f16 = -this.m01 * f11 + this.m02 * f10 - this.m03 * f9;
float f17 = this.m00 * f11 - this.m02 * f8 + this.m03 * f7;
float f18 = -this.m00 * f10 + this.m01 * f8 - this.m03 * f6;
float f19 = this.m00 * f9 - this.m01 * f7 + this.m02 * f6;
float f20 = this.m31 * f5 - this.m32 * f4 + this.m33 * f3;
float f21 = -this.m30 * f5 + this.m32 * f2 - this.m33 * f1;
float f22 = this.m30 * f4 - this.m31 * f2 + this.m33 * f;
float f23 = -this.m30 * f3 + this.m31 * f1 - this.m32 * f;
float f24 = -this.m21 * f5 + this.m22 * f4 - this.m23 * f3;
float f25 = this.m20 * f5 - this.m22 * f2 + this.m23 * f1;
float f26 = -this.m20 * f4 + this.m21 * f2 - this.m23 * f;
float f27 = this.m20 * f3 - this.m21 * f1 + this.m22 * f;
this.m00 = f12;
this.m10 = f13;
this.m20 = f14;
this.m30 = f15;
this.m01 = f16;
this.m11 = f17;
this.m21 = f18;
this.m31 = f19;
this.m02 = f20;
this.m12 = f21;
this.m22 = f22;
this.m32 = f23;
this.m03 = f24;
this.m13 = f25;
this.m23 = f26;
this.m33 = f27;
return f * f11 - f1 * f10 + f2 * f9 + f3 * f8 - f4 * f7 + f5 * f6;
}
public void transpose()
{
float f = this.m10;
this.m10 = this.m01;
this.m01 = f;
f = this.m20;
this.m20 = this.m02;
this.m02 = f;
f = this.m21;
this.m21 = this.m12;
this.m12 = f;
f = this.m30;
this.m30 = this.m03;
this.m03 = f;
f = this.m31;
this.m31 = this.m13;
this.m13 = f;
f = this.m32;
this.m32 = this.m23;
this.m23 = f;
}
public boolean invert()
{
float det = this.adjudicateAndDet();
if (Math.abs(det) > 1.0E-6F)
{
this.multiply(det);
return true;
}
else
{
return false;
}
}
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;
float f2 = this.m00 * multMatrix.m02 + this.m01 * multMatrix.m12 + this.m02 * multMatrix.m22 + this.m03 * multMatrix.m32;
float f3 = this.m00 * multMatrix.m03 + this.m01 * multMatrix.m13 + this.m02 * multMatrix.m23 + this.m03 * multMatrix.m33;
float f4 = this.m10 * multMatrix.m00 + this.m11 * multMatrix.m10 + this.m12 * multMatrix.m20 + this.m13 * multMatrix.m30;
float f5 = this.m10 * multMatrix.m01 + this.m11 * multMatrix.m11 + this.m12 * multMatrix.m21 + this.m13 * multMatrix.m31;
float f6 = this.m10 * multMatrix.m02 + this.m11 * multMatrix.m12 + this.m12 * multMatrix.m22 + this.m13 * multMatrix.m32;
float f7 = this.m10 * multMatrix.m03 + this.m11 * multMatrix.m13 + this.m12 * multMatrix.m23 + this.m13 * multMatrix.m33;
float f8 = this.m20 * multMatrix.m00 + this.m21 * multMatrix.m10 + this.m22 * multMatrix.m20 + this.m23 * multMatrix.m30;
float f9 = this.m20 * multMatrix.m01 + this.m21 * multMatrix.m11 + this.m22 * multMatrix.m21 + this.m23 * multMatrix.m31;
float f10 = this.m20 * multMatrix.m02 + this.m21 * multMatrix.m12 + this.m22 * multMatrix.m22 + this.m23 * multMatrix.m32;
float f11 = this.m20 * multMatrix.m03 + this.m21 * multMatrix.m13 + this.m22 * multMatrix.m23 + this.m23 * multMatrix.m33;
float f12 = this.m30 * multMatrix.m00 + this.m31 * multMatrix.m10 + this.m32 * multMatrix.m20 + this.m33 * multMatrix.m30;
float f13 = this.m30 * multMatrix.m01 + this.m31 * multMatrix.m11 + this.m32 * multMatrix.m21 + this.m33 * multMatrix.m31;
float f14 = this.m30 * multMatrix.m02 + this.m31 * multMatrix.m12 + this.m32 * multMatrix.m22 + this.m33 * multMatrix.m32;
float f15 = this.m30 * multMatrix.m03 + this.m31 * multMatrix.m13 + this.m32 * multMatrix.m23 + this.m33 * multMatrix.m33;
this.m00 = f;
this.m01 = f1;
this.m02 = f2;
this.m03 = f3;
this.m10 = f4;
this.m11 = f5;
this.m12 = f6;
this.m13 = f7;
this.m20 = f8;
this.m21 = f9;
this.m22 = f10;
this.m23 = f11;
this.m30 = f12;
this.m31 = f13;
this.m32 = f14;
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;
this.m01 *= scalar;
this.m02 *= scalar;
this.m03 *= scalar;
this.m10 *= scalar;
this.m11 *= scalar;
this.m12 *= scalar;
this.m13 *= scalar;
this.m20 *= scalar;
this.m21 *= scalar;
this.m22 *= scalar;
this.m23 *= scalar;
this.m30 *= scalar;
this.m31 *= scalar;
this.m32 *= scalar;
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;
}
//==================//
// Distant Horizons //
// methods //
//==================//
/** Returns the values of this matrix in row major order (AKA rows then columns) */
public float[] getValuesAsArray()
{
return new float[] {
this.m00,
this.m01,
this.m02,
this.m03,
this.m10,
this.m11,
this.m12,
this.m13,
this.m20,
this.m21,
this.m22,
this.m23,
this.m30,
this.m31,
this.m32,
this.m33,
};
}
//===============//
// Forge methods //
//===============//
public Mat4f(float[] values)
{
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];
}
public Mat4f(FloatBuffer buffer)
{
this(buffer.array());
}
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;
}
}
@@ -0,0 +1,257 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.util.math;
import com.seibel.lod.core.util.MathUtil;
/**
* This is closer to MC's implementation of a
* 3 element float vector than a 3 element double
* vector. Hopefully that shouldn't cause any issues.
*
* @author James Seibel
* @version 11-18-2021
*/
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);
public static Vec3d YNeg = new Vec3d(0.0F, -1.0F, 0.0F);
public static Vec3d YPos = new Vec3d(0.0F, 1.0F, 0.0F);
public static Vec3d ZNeg = new Vec3d(0.0F, 0.0F, -1.0F);
public static Vec3d ZPos = new Vec3d(0.0F, 0.0F, 1.0F);
public static final Vec3d ZERO_VECTOR = new Vec3d(0.0D, 0.0D, 0.0D);
public double x;
public double y;
public double z;
public Vec3d()
{
}
public Vec3d(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())
{
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;
}
}
@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)
{
this.x *= scalar;
this.y *= scalar;
this.z *= scalar;
}
public void mul(double x, double y, double z)
{
this.x *= x;
this.y *= y;
this.z *= z;
}
public void clamp(double min, double 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(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
public void add(double x, double y, double z)
{
this.x += x;
this.y += y;
this.z += z;
}
public void add(Vec3d vector)
{
this.x += vector.x;
this.y += vector.y;
this.z += vector.z;
}
public void subtract(Vec3d vector)
{
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()
{
double value = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
return value < 1.0E-4D ? ZERO_VECTOR : new Vec3d(this.x / value, this.y / value, this.z / value);
}
public void crossProduct(Vec3d vector)
{
double f = this.x;
double f1 = this.y;
double f2 = this.z;
double f3 = vector.x;
double f4 = vector.y;
double 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_)
{
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;
}
*/
/* 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)
{
this.x = values[0];
this.y = values[1];
this.z = values[2];
}
}
@@ -0,0 +1,261 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.util.math;
import com.seibel.lod.core.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;
}
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];
}
}
@@ -0,0 +1,203 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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.lod.core.util.math;
import com.seibel.lod.core.util.MathUtil;
/**
* A (almost) exact copy of Minecraft's 1.16.5
* implementation of a 3 element integer vector.
*
* @author James Seibel
* @version 11-11-2021
*/
public class Vec3i
{
public static Vec3i XNeg = new Vec3i(-1, 0, 0);
public static Vec3i XPos = new Vec3i(1, 0, 0);
public static Vec3i YNeg = new Vec3i(0, -1, 0);
public static Vec3i YPos = new Vec3i(0, 1, 0);
public static Vec3i ZNeg = new Vec3i(0, 0, -1);
public static Vec3i ZPos = new Vec3i(0, 0, 1);
public int x;
public int y;
public int z;
public Vec3i()
{
}
public Vec3i(int x, int y, int 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())
{
Vec3i Vec3f = (Vec3i) 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(int min, int 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(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
public void add(int x, int y, int z)
{
this.x += x;
this.y += y;
this.z += z;
}
public void add(Vec3i vector)
{
this.x += vector.x;
this.y += vector.y;
this.z += vector.z;
}
public void subtract(Vec3i vector)
{
this.x -= vector.x;
this.y -= vector.y;
this.z -= vector.z;
}
public double distSqr(double x, double y, double z, boolean centerOfBlock)
{
double offset = centerOfBlock ? 0.5 : 0.0;
double xAdd = this.x + offset - x;
double yAdd = this.y + offset - y;
double zAdd = this.z + offset - z;
return (xAdd * xAdd) + (yAdd * yAdd) + (zAdd * zAdd);
}
public int distManhattan(Vec3i otherVec)
{
float xSub = Math.abs(otherVec.x - this.x);
float ySub = Math.abs(otherVec.y - this.y);
float zSub = Math.abs(otherVec.z - this.z);
return (int) (xSub + ySub + zSub);
}
/** inner product */
public float dotProduct(Vec3i vector)
{
return (this.x * vector.x) + (this.y * vector.y) + (this.z * vector.z);
}
/** Cross product */
public Vec3i cross(Vec3i otherVec)
{
return new Vec3i(
(this.y * otherVec.z) - (this.z * otherVec.y),
(this.z * otherVec.x) - (this.x * otherVec.z),
(this.x * otherVec.y) - (this.y * otherVec.x));
}
public Vec3i copy()
{
return new Vec3i(this.x, this.y, this.z);
}
@Override
public String toString()
{
return "[" + this.x + ", " + this.y + ", " + this.z + "]";
}
// Forge start
public Vec3i(int[] values)
{
set(values);
}
public void set(int[] values)
{
this.x = values[0];
this.y = values[1];
this.z = values[2];
}
}
@@ -1,12 +1,6 @@
package testItems.events.abstractObjects;
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
import com.seibel.lod.api.items.objects.wrappers.DhApiLevelWrapper;
import com.seibel.lod.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
import com.seibel.lod.api.methods.events.interfaces.IDhApiEvent;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiLevelLoadEvent;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiTestEvent;
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
/**
* A dummy event implementation used for unit testing.
@@ -15,12 +9,15 @@ import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
* @version 2022-9-11
*/
public abstract class DhApiTestEvent
extends CoreDhApiTestEvent
implements IDhApiEvent<Boolean, Boolean>
implements IDhApiEvent<Boolean>
{
public abstract void onTestEvent(Boolean input);
/** just used for testing */
public abstract boolean getTestValue();
//=========================//
// internal DH API methods //
@@ -1,129 +0,0 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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 tests;
import com.seibel.lod.api.enums.DhApiEnumAssembly;
import com.seibel.lod.core.enums.rendering.EFogDrawMode;
import com.seibel.lod.core.enums.CoreEnumAssembly;
import com.seibel.lod.core.enums.config.EVerticalQuality;
import com.seibel.lod.core.util.EnumUtil;
import org.junit.Test;
import org.junit.Assert;
import java.util.ArrayList;
/**
* These tests were primary created to confirm that the
* API enums are properly synced with their Core variants.
*
* @author James Seibel
* @version 2022-6-9
*/
public class ApiEnumSyncTests
{
/** Make sure each DhApi enum has the same values as its corresponding core enum. */
// @Test
public void ConfirmEnumsAreSynced()
{
//=================//
// test validation //
//=================//
// this should always succeed (comparing an enum to itself)
AssertEnumsValuesAreEqual(EnumUtil.compareEnumClassesByValues(EVerticalQuality.class, EVerticalQuality.class), true);
// this should always fail (two completely different enums)
AssertEnumsValuesAreEqual(EnumUtil.compareEnumClassesByValues(EVerticalQuality.class, EFogDrawMode.class), false);
//================//
// Api enum Setup //
//================//
// make sure the enum packages are loaded
new DhApiEnumAssembly();
new CoreEnumAssembly();
// get the list of API enums
ArrayList<Class<? extends Enum<?>>> apiEnumClassList = new ArrayList<>();
ArrayList<String> apiConfigEnumPackageNames = EnumTestHelper.findPackageNamesStartingWith(DhApiEnumAssembly.class.getPackage().getName());
for (String apiEnumPackageName : apiConfigEnumPackageNames)
{
apiEnumClassList.addAll(EnumTestHelper.getAllEnumsFromPackage(apiEnumPackageName));
}
// get the list of core enums
ArrayList<Class<? extends Enum<?>>> coreEnumClassList = new ArrayList<>();
ArrayList<String> coreEnumPackageNames = EnumTestHelper.findPackageNamesStartingWith(CoreEnumAssembly.class.getPackage().getName());
for (String coreEnumPackageName : coreEnumPackageNames)
{
coreEnumClassList.addAll(EnumTestHelper.getAllEnumsFromPackage(coreEnumPackageName));
}
//======================//
// Api enum comparisons //
//======================//
// compare each API enum to its corresponding Core enum
for (Class<? extends Enum<?>> apiEnumClass : apiEnumClassList)
{
String coreEnumName = CoreEnumAssembly.ENUM_PREFIX + apiEnumClass.getSimpleName().substring(DhApiEnumAssembly.API_ENUM_PREFIX.length());
boolean coreEnumFound = false;
// find the core enum to compare against
for (Class<? extends Enum<?>> coreEnumClass : coreEnumClassList)
{
if (coreEnumClass.getSimpleName().equals(coreEnumName))
{
AssertEnumsValuesAreEqual(EnumUtil.compareEnumClassesByValues(coreEnumClass, apiEnumClass), true);
coreEnumFound = true;
break;
}
}
if (!coreEnumFound)
{
Assert.fail("API enum [" + coreEnumName + "] not found in Core.");
}
}
}
/** Helper method to make enum comparisons a little cleaner */
private void AssertEnumsValuesAreEqual(EnumUtil.EnumComparisonResult comparisonResult, boolean assertEqual)
{
if (assertEqual)
{
Assert.assertTrue(comparisonResult.failMessage, comparisonResult.success);
}
else
{
Assert.assertFalse(comparisonResult.failMessage, comparisonResult.success);
}
}
}
-184
View File
@@ -1,184 +0,0 @@
package tests;/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 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/>.
*/
import org.junit.Assert;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
/**
* A list of methods related to the Enum unit tests.
*
* @author James Seibel
* @version 2022-9-5
*/
public class EnumTestHelper
{
/**
* Returns a list of every Enum in the package with the given full name.
*
* @param packageFullName includes the package path
*/
@SuppressWarnings("unchecked")
public static ArrayList<Class<? extends Enum<?>>> getAllEnumsFromPackage(String packageFullName)
{
ArrayList<Class<? extends Enum<?>>> enumList = new ArrayList<>();
List<Class<?>> classesInPackage = getClassesInPackage(packageFullName, true, "DistantHorizons");
// get the enums from each file
Assert.assertTrue("No files found in the package [" + packageFullName + "].", classesInPackage.size() != 0);
for (Class<?> clazz : classesInPackage)
{
// ignore internal classes
if (!clazz.getName().contains("$"))
{
// attempt to parse the file's class into an enum
if (Enum.class.isAssignableFrom(clazz))
{
enumList.add((Class<? extends Enum<?>>) clazz);
}
else
{
System.out.println("The Class [" + clazz + "] isn't an enum.");
}
}
}
return enumList;
}
/**
* Returns every class in the given package. <br><br>
*
* Originally from:
* https://stackoverflow.com/questions/28678026/how-can-i-get-all-class-files-in-a-specific-package-in-java
*
* @param packageName
* @param onlySearchJars if true only jar files will be searched, otherwise jars and loose files will be searched
* @param expectedJarPathString Only search jars that contain this string
*/
public static List<Class<?>> getClassesInPackage(String packageName, boolean onlySearchJars, String expectedJarPathString)
{
String path = packageName.replace('.', '/');
List<Class<?>> classes = new ArrayList<>();
String[] classPathEntries = System.getProperty("java.class.path").split(
System.getProperty("path.separator")
);
String name;
for (String classpathEntry : classPathEntries)
{
if (classpathEntry.endsWith(".jar") && classpathEntry.toLowerCase().contains(expectedJarPathString.toLowerCase()))
{
File jar = new File(classpathEntry);
try
{
JarInputStream is = new JarInputStream(new FileInputStream(jar));
JarEntry entry;
while ((entry = is.getNextJarEntry()) != null)
{
name = entry.getName();
if (name.endsWith(".class"))
{
if (name.contains(path) && name.endsWith(".class"))
{
try
{
String classPath = name.substring(0, entry.getName().length() - 6);
classPath = classPath.replaceAll("[\\|/]", ".");
classes.add(Class.forName(classPath));
}
catch (ClassNotFoundException ex)
{
// the class wasn't found
System.err.println("The Class [" + packageName + "." + name + "] failed to load.");
}
}
}
}
}
catch (IOException e)
{
System.err.println("Error reading the jar [" + jar.getPath() + "].");
}
}
else if (!onlySearchJars)
{
File base = new File(classpathEntry + File.separatorChar + path);
File[] files = base.listFiles();
if (files != null)
{
for (File file : files)
{
try
{
name = file.getName();
if (name.endsWith(".class"))
{
name = name.substring(0, name.length() - 6);
classes.add(Class.forName(packageName + "." + name));
}
}
catch (ClassNotFoundException ex)
{
// the class wasn't found
System.err.println("The Class [" + packageName + "." + file.getName() + "] failed to load.");
}
}
}
}
}
return classes;
}
/**
* Returns every loaded package that begins with the given string. <br>
*
* Note: this will only search packages that have been loaded
* at some point during the JVM's lifetime.
* To Make sure the package(s) you want to find are loaded you can
* initialize an object from that package to load it.
*/
public static ArrayList<String> findPackageNamesStartingWith(String packagePrefix)
{
ArrayList<String> nestedPackages = new ArrayList<>();
// search all the loaded packages
Package[] packageArray = Package.getPackages();
for (Package pack : packageArray)
{
String packageName = pack.getName();
if (packageName.startsWith(packagePrefix))
{
nestedPackages.add(packageName);
}
}
return nestedPackages;
}
}
+60 -62
View File
@@ -1,7 +1,5 @@
package tests;
import com.seibel.lod.core.api.external.coreImplementations.objects.events.abstractEvents.CoreDhApiTestEvent;
import com.seibel.lod.core.dependencyInjection.DhApiEventInjector;
import org.junit.Assert;
import testItems.events.abstractObjects.DhApiTestEvent;
import testItems.events.objects.DhTestEvent;
@@ -17,66 +15,66 @@ import java.util.ArrayList;
public class EventInjectorTest
{
//@Test
public void testEventDependencies() // this also tests list dependencies since there can be more than one event handler bound per event
{
// Injector setup
DhApiEventInjector TEST_EVENT_HANDLER = new DhApiEventInjector();
// pre-dependency setup
Assert.assertNull("Nothing should have been bound.", TEST_EVENT_HANDLER.get(DhApiTestEvent.class));
// dependency setup
TEST_EVENT_HANDLER.bind(DhApiTestEvent.class, new DhTestEvent());
TEST_EVENT_HANDLER.bind(DhApiTestEvent.class, new DhTestEventAlt());
TEST_EVENT_HANDLER.runDelayedSetup();
// get first
CoreDhApiTestEvent afterRenderEvent = TEST_EVENT_HANDLER.get(CoreDhApiTestEvent.class);
Assert.assertNotNull("Event not bound.", afterRenderEvent);
// get list
ArrayList<CoreDhApiTestEvent> afterRenderEventList = TEST_EVENT_HANDLER.getAll(CoreDhApiTestEvent.class);
Assert.assertEquals("Bound list doesn't contain the correct number of items.", 2, afterRenderEventList.size());
// object one
Assert.assertNotNull("Event not bound.", afterRenderEventList.get(0));
Assert.assertEquals("First event object setup incorrectly.", null, afterRenderEventList.get(0).getTestValue());
// object two
Assert.assertNotNull("Event not bound.", afterRenderEventList.get(1));
Assert.assertEquals("First event object setup incorrectly.", null, afterRenderEventList.get(1).getTestValue());
// event firing
Assert.assertEquals("fireAllEvents canceled returned canceled incorrectly.", true, TEST_EVENT_HANDLER.fireAllEvents(CoreDhApiTestEvent.class, true));
// object one
Assert.assertEquals("Event not fired for first object.", true, afterRenderEventList.get(0).getTestValue());
// object two
Assert.assertEquals("Event not fired for second object.", true, afterRenderEventList.get(1).getTestValue());
// unbind
CoreDhApiTestEvent unboundEvent = afterRenderEventList.get(0);
Assert.assertTrue("Unbind should've removed item.", TEST_EVENT_HANDLER.unbind(CoreDhApiTestEvent.class, DhTestEvent.class));
Assert.assertFalse("Unbind should've already removed item.", TEST_EVENT_HANDLER.unbind(CoreDhApiTestEvent.class, DhTestEvent.class));
// check unbinding
afterRenderEventList = TEST_EVENT_HANDLER.getAll(CoreDhApiTestEvent.class);
Assert.assertEquals("Unbound list doesn't contain the correct number of items.", 1, afterRenderEventList.size());
Assert.assertNotNull("Unbinding removed all items.", afterRenderEventList.get(0));
// check unbound event firing
Assert.assertEquals("fireAllEvents canceled returned canceled incorrectly.", false, TEST_EVENT_HANDLER.fireAllEvents(CoreDhApiTestEvent.class, false));
// remaining event
Assert.assertEquals("Event not fired for remaining object.", false, ((DhTestEventAlt) afterRenderEventList.get(0)).eventFiredValue);
// unbound event
Assert.assertEquals("Event fired for unbound object.", true, unboundEvent.getTestValue());
}
// //@Test
// public void testEventDependencies() // this also tests list dependencies since there can be more than one event handler bound per event
// {
// // Injector setup
// DhApiEventInjector TEST_EVENT_HANDLER = new DhApiEventInjector();
//
//
// // pre-dependency setup
// Assert.assertNull("Nothing should have been bound.", TEST_EVENT_HANDLER.get(DhApiTestEvent.class));
//
//
// // dependency setup
// TEST_EVENT_HANDLER.bind(DhApiTestEvent.class, new DhTestEvent());
// TEST_EVENT_HANDLER.bind(DhApiTestEvent.class, new DhTestEventAlt());
// TEST_EVENT_HANDLER.runDelayedSetup();
//
//
// // get first
// CoreDhApiTestEvent afterRenderEvent = TEST_EVENT_HANDLER.get(CoreDhApiTestEvent.class);
// Assert.assertNotNull("Event not bound.", afterRenderEvent);
//
//
// // get list
// ArrayList<CoreDhApiTestEvent> afterRenderEventList = TEST_EVENT_HANDLER.getAll(CoreDhApiTestEvent.class);
// Assert.assertEquals("Bound list doesn't contain the correct number of items.", 2, afterRenderEventList.size());
// // object one
// Assert.assertNotNull("Event not bound.", afterRenderEventList.get(0));
// Assert.assertEquals("First event object setup incorrectly.", null, afterRenderEventList.get(0).getTestValue());
// // object two
// Assert.assertNotNull("Event not bound.", afterRenderEventList.get(1));
// Assert.assertEquals("First event object setup incorrectly.", null, afterRenderEventList.get(1).getTestValue());
//
//
// // event firing
// Assert.assertEquals("fireAllEvents canceled returned canceled incorrectly.", true, TEST_EVENT_HANDLER.fireAllEvents(CoreDhApiTestEvent.class, true));
// // object one
// Assert.assertEquals("Event not fired for first object.", true, afterRenderEventList.get(0).getTestValue());
// // object two
// Assert.assertEquals("Event not fired for second object.", true, afterRenderEventList.get(1).getTestValue());
//
//
// // unbind
// CoreDhApiTestEvent unboundEvent = afterRenderEventList.get(0);
// Assert.assertTrue("Unbind should've removed item.", TEST_EVENT_HANDLER.unbind(CoreDhApiTestEvent.class, DhTestEvent.class));
// Assert.assertFalse("Unbind should've already removed item.", TEST_EVENT_HANDLER.unbind(CoreDhApiTestEvent.class, DhTestEvent.class));
//
// // check unbinding
// afterRenderEventList = TEST_EVENT_HANDLER.getAll(CoreDhApiTestEvent.class);
// Assert.assertEquals("Unbound list doesn't contain the correct number of items.", 1, afterRenderEventList.size());
// Assert.assertNotNull("Unbinding removed all items.", afterRenderEventList.get(0));
//
//
// // check unbound event firing
// Assert.assertEquals("fireAllEvents canceled returned canceled incorrectly.", false, TEST_EVENT_HANDLER.fireAllEvents(CoreDhApiTestEvent.class, false));
// // remaining event
// Assert.assertEquals("Event not fired for remaining object.", false, ((DhTestEventAlt) afterRenderEventList.get(0)).eventFiredValue);
// // unbound event
// Assert.assertEquals("Event fired for unbound object.", true, unboundEvent.getTestValue());
//
// }
}