diff --git a/src/main/java/com/seibel/lod/core/api/external/config/objects/enums/DhApiEnumAssembly.java b/src/main/java/com/seibel/lod/core/api/external/config/objects/enums/DhApiConfigEnumAssembly.java similarity index 90% rename from src/main/java/com/seibel/lod/core/api/external/config/objects/enums/DhApiEnumAssembly.java rename to src/main/java/com/seibel/lod/core/api/external/config/objects/enums/DhApiConfigEnumAssembly.java index 4bb959171..e207f7a65 100644 --- a/src/main/java/com/seibel/lod/core/api/external/config/objects/enums/DhApiEnumAssembly.java +++ b/src/main/java/com/seibel/lod/core/api/external/config/objects/enums/DhApiConfigEnumAssembly.java @@ -23,9 +23,9 @@ package com.seibel.lod.core.api.external.config.objects.enums; * Assembly classes are used to reference the package they are in. * * @author James Seibel - * @version 2022-6-9 + * @version 2022-7-13 */ -public class DhApiEnumAssembly +public class DhApiConfigEnumAssembly { - public static final String API_ENUM_PREFIX = "EDhApi"; + } diff --git a/src/main/java/com/seibel/lod/core/api/external/data/DhApiTerrainDataRepo.java b/src/main/java/com/seibel/lod/core/api/external/data/DhApiTerrainDataRepo.java index 0e282b4e8..0a3c743c0 100644 --- a/src/main/java/com/seibel/lod/core/api/external/data/DhApiTerrainDataRepo.java +++ b/src/main/java/com/seibel/lod/core/api/external/data/DhApiTerrainDataRepo.java @@ -1,7 +1,7 @@ package com.seibel.lod.core.api.external.data; import com.seibel.lod.core.api.external.data.objects.DhApiTerrainDataPoint; -import com.seibel.lod.core.api.external.sharedObjects.DhApiResult; +import com.seibel.lod.core.api.external.shared.objects.DhApiResult; /** diff --git a/src/main/java/com/seibel/lod/core/api/external/events/DhApiEventRegister.java b/src/main/java/com/seibel/lod/core/api/external/events/DhApiEventRegister.java index ee3f58a0c..33afb4bc8 100644 --- a/src/main/java/com/seibel/lod/core/api/external/events/DhApiEventRegister.java +++ b/src/main/java/com/seibel/lod/core/api/external/events/DhApiEventRegister.java @@ -1,7 +1,7 @@ package com.seibel.lod.core.api.external.events; import com.seibel.lod.core.api.external.events.interfaces.IDhApiEvent; -import com.seibel.lod.core.api.external.sharedObjects.DhApiResult; +import com.seibel.lod.core.api.external.shared.objects.DhApiResult; /** * Handles adding/removing event handlers. diff --git a/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiAfterRenderEvent.java b/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiAfterRenderEvent.java index 4fccce195..0623fabad 100644 --- a/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiAfterRenderEvent.java +++ b/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiAfterRenderEvent.java @@ -1,7 +1,7 @@ package com.seibel.lod.core.api.external.events.interfaces; -import com.seibel.lod.core.objects.math.Mat4f; -import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper; +import com.seibel.lod.core.api.external.shared.interfaces.IDhApiLevelWrapper; +import com.seibel.lod.core.api.external.shared.objects.math.DhApiMat4f; /** * @author James Seibel @@ -14,6 +14,9 @@ public interface IDhApiAfterRenderEvent extends IDhApiEvent * * @param renderingEnabled Passes in false if DH rendering was disabled or canceled for this frame. */ - void afterRender(ILevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, boolean renderingEnabled); + void afterRender(IDhApiLevelWrapper levelWrapper, + DhApiMat4f mcModelViewMatrix, DhApiMat4f mcProjectionMatrix, // the matrices received from Minecraft + DhApiMat4f dhModelViewMatrix, DhApiMat4f dhProjectionMatrix, // the matrices used by Distant Horizons + float partialTicks, boolean renderingEnabled); } \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiBeforeRenderEvent.java b/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiBeforeRenderEvent.java index 7f64d124c..437ab4f0c 100644 --- a/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiBeforeRenderEvent.java +++ b/src/main/java/com/seibel/lod/core/api/external/events/interfaces/IDhApiBeforeRenderEvent.java @@ -1,7 +1,7 @@ package com.seibel.lod.core.api.external.events.interfaces; -import com.seibel.lod.core.objects.math.Mat4f; -import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper; +import com.seibel.lod.core.api.external.shared.interfaces.IDhApiLevelWrapper; +import com.seibel.lod.core.api.external.shared.objects.math.DhApiMat4f; /** * @author James Seibel @@ -9,13 +9,16 @@ import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper; */ public interface IDhApiBeforeRenderEvent extends IDhApiEvent { - // TODO should we allow editing the levelWrapper MVM matrix, etc.? - // TODO make sure to document it either way. - /** * Called before Distant Horizons starts rendering.
- * If this methods returns false, DH's rendering will be skipped for that frame. + * If this method returns false; DH's rendering will be skipped for that frame.

+ * + * The Matrices received are not passed on to the renderer and can be safely + * edited without modifying Minecraft or Distant Horizons' rendering. */ - boolean beforeRender(ILevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks); + boolean beforeRender(IDhApiLevelWrapper levelWrapper, + DhApiMat4f mcModelViewMatrix, DhApiMat4f mcProjectionMatrix, // the matrices received from Minecraft + DhApiMat4f dhModelViewMatrix, DhApiMat4f dhProjectionMatrix, // the matrices used by Distant Horizons + float partialTicks); } \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/core/api/external/shared/Readme.md b/src/main/java/com/seibel/lod/core/api/external/shared/Readme.md new file mode 100644 index 000000000..c77fc0ea0 --- /dev/null +++ b/src/main/java/com/seibel/lod/core/api/external/shared/Readme.md @@ -0,0 +1 @@ +the shared package contains objects, interfaces, methods, etc. used by one or more api packages. \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/core/api/external/shared/enums/DhApiSharedEnumAssembly.java b/src/main/java/com/seibel/lod/core/api/external/shared/enums/DhApiSharedEnumAssembly.java new file mode 100644 index 000000000..ca0cdd38a --- /dev/null +++ b/src/main/java/com/seibel/lod/core/api/external/shared/enums/DhApiSharedEnumAssembly.java @@ -0,0 +1,31 @@ +/* + * 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 . + */ + +package com.seibel.lod.core.api.external.shared.enums; + +/** + * Assembly classes are used to reference the package they are in. + * + * @author James Seibel + * @version 2022-7-13 + */ +public class DhApiSharedEnumAssembly +{ + public static final String API_ENUM_PREFIX = "EDhApi"; +} diff --git a/src/main/java/com/seibel/lod/core/api/external/shared/enums/EDhApiLevelType.java b/src/main/java/com/seibel/lod/core/api/external/shared/enums/EDhApiLevelType.java new file mode 100644 index 000000000..836c44c27 --- /dev/null +++ b/src/main/java/com/seibel/lod/core/api/external/shared/enums/EDhApiLevelType.java @@ -0,0 +1,16 @@ +package com.seibel.lod.core.api.external.shared.enums; + +/** + * SERVER_LEVEL,
+ * CLIENT_LEVEL,
+ * UNKNOWN
+ * + * @author James Seibel + * @version 2022-7-13 + */ +public enum EDhApiLevelType +{ + SERVER_LEVEL, + CLIENT_LEVEL, + UNKNOWN +} diff --git a/src/main/java/com/seibel/lod/core/api/external/shared/interfaces/IDhApiDimensionTypeWrapper.java b/src/main/java/com/seibel/lod/core/api/external/shared/interfaces/IDhApiDimensionTypeWrapper.java new file mode 100644 index 000000000..bf16c135e --- /dev/null +++ b/src/main/java/com/seibel/lod/core/api/external/shared/interfaces/IDhApiDimensionTypeWrapper.java @@ -0,0 +1,33 @@ +/* + * 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 . + */ + +package com.seibel.lod.core.api.external.shared.interfaces; + +/** + * @author James Seibel + * @version 2022-7-13 + */ +public interface IDhApiDimensionTypeWrapper +{ + String getDimensionName(); + + boolean hasCeiling(); + + boolean hasSkyLight(); +} diff --git a/src/main/java/com/seibel/lod/core/api/external/shared/interfaces/IDhApiLevelWrapper.java b/src/main/java/com/seibel/lod/core/api/external/shared/interfaces/IDhApiLevelWrapper.java new file mode 100644 index 000000000..b3c323f2b --- /dev/null +++ b/src/main/java/com/seibel/lod/core/api/external/shared/interfaces/IDhApiLevelWrapper.java @@ -0,0 +1,49 @@ +/* + * 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 . + */ + +package com.seibel.lod.core.api.external.shared.interfaces; + +import com.seibel.lod.core.api.external.shared.enums.EDhApiLevelType; + +/** + * Can be either a Server or Client level. + * + * @author James Seibel + * @version 2022-7-13 + */ +public interface IDhApiLevelWrapper +{ + IDhApiDimensionTypeWrapper getDimensionType(); + + EDhApiLevelType getLevelType(); + + boolean hasCeiling(); + + boolean hasSkyLight(); + + int getHeight(); + + int getSeaLevel(); + + default short getMinHeight() + { + return 0; + } + +} diff --git a/src/main/java/com/seibel/lod/core/api/external/sharedObjects/DhApiResult.java b/src/main/java/com/seibel/lod/core/api/external/shared/objects/DhApiResult.java similarity index 89% rename from src/main/java/com/seibel/lod/core/api/external/sharedObjects/DhApiResult.java rename to src/main/java/com/seibel/lod/core/api/external/shared/objects/DhApiResult.java index 14280b44e..f053fd546 100644 --- a/src/main/java/com/seibel/lod/core/api/external/sharedObjects/DhApiResult.java +++ b/src/main/java/com/seibel/lod/core/api/external/shared/objects/DhApiResult.java @@ -1,4 +1,4 @@ -package com.seibel.lod.core.api.external.sharedObjects; +package com.seibel.lod.core.api.external.shared.objects; /** * Allows for more descriptive non-critical failure states. diff --git a/src/main/java/com/seibel/lod/core/api/external/shared/objects/math/DhApiMat4f.java b/src/main/java/com/seibel/lod/core/api/external/shared/objects/math/DhApiMat4f.java new file mode 100644 index 000000000..c813a7075 --- /dev/null +++ b/src/main/java/com/seibel/lod/core/api/external/shared/objects/math/DhApiMat4f.java @@ -0,0 +1,171 @@ +/* + * 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 . + */ + +package com.seibel.lod.core.api.external.shared.objects.math; + +/** + * 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. + *
+ * Based on Minecraft 1.16's implementation + * of a 4x4 matrix. + * + * @author James Seibel + * @version 2022-7-13 + */ +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]; + } + + + + + + + @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"; + } + + +} diff --git a/src/main/java/com/seibel/lod/core/api/external/sharedObjects/Readme.md b/src/main/java/com/seibel/lod/core/api/external/sharedObjects/Readme.md deleted file mode 100644 index 20035db2a..000000000 --- a/src/main/java/com/seibel/lod/core/api/external/sharedObjects/Readme.md +++ /dev/null @@ -1 +0,0 @@ -the sharedObjects package contains objects used by one or more different api packages. \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/core/enums/ELevelType.java b/src/main/java/com/seibel/lod/core/enums/ELevelType.java index 5acdb4a51..d1d212af0 100644 --- a/src/main/java/com/seibel/lod/core/enums/ELevelType.java +++ b/src/main/java/com/seibel/lod/core/enums/ELevelType.java @@ -20,14 +20,16 @@ package com.seibel.lod.core.enums; /** - * ServerWorld, ClientWorld, Unknown - * + * SERVER_LEVEL,
+ * CLIENT_LEVEL,
+ * UNKNOWN
+ * * @author James Seibel - * @version 11-12-2021 + * @version 2022-7-13 */ public enum ELevelType { - ServerLevel, - ClientLevel, - Unknown + SERVER_LEVEL, + CLIENT_LEVEL, + UNKNOWN } diff --git a/src/main/java/com/seibel/lod/core/objects/math/Mat4f.java b/src/main/java/com/seibel/lod/core/objects/math/Mat4f.java index 035734ef3..9d3f94f31 100644 --- a/src/main/java/com/seibel/lod/core/objects/math/Mat4f.java +++ b/src/main/java/com/seibel/lod/core/objects/math/Mat4f.java @@ -22,7 +22,7 @@ package com.seibel.lod.core.objects.math; import java.nio.FloatBuffer; /** - * A (almost) exact copy of Minecraft's 1.16.5 + * An (almost) exact copy of Minecraft's 1.16.5 * implementation of a 4x4 float matrix. * * @author James Seibel diff --git a/src/test/java/ApiEnumSyncTests.java b/src/test/java/ApiEnumSyncTests.java index 7323dd891..91762826c 100644 --- a/src/test/java/ApiEnumSyncTests.java +++ b/src/test/java/ApiEnumSyncTests.java @@ -17,7 +17,8 @@ * along with this program. If not, see . */ -import com.seibel.lod.core.api.external.config.objects.enums.DhApiEnumAssembly; +import com.seibel.lod.core.api.external.config.objects.enums.DhApiConfigEnumAssembly; +import com.seibel.lod.core.api.external.shared.enums.DhApiSharedEnumAssembly; import com.seibel.lod.core.enums.rendering.EFogDrawMode; import com.seibel.lod.core.enums.CoreEnumAssembly; import com.seibel.lod.core.enums.config.EVerticalQuality; @@ -66,16 +67,25 @@ public class ApiEnumSyncTests //================// // make sure the enum packages are loaded - new DhApiEnumAssembly(); + new DhApiConfigEnumAssembly(); + new DhApiSharedEnumAssembly(); new CoreEnumAssembly(); // get the list of API enums ArrayList>> apiEnumClassList = new ArrayList<>(); - ArrayList apiEnumPackageNames = EnumTestHelper.findPackageNamesStartingWith(DhApiEnumAssembly.class.getPackage().getName()); - for (String apiEnumPackageName : apiEnumPackageNames) + // get the config enums + ArrayList apiConfigEnumPackageNames = EnumTestHelper.findPackageNamesStartingWith(DhApiConfigEnumAssembly.class.getPackage().getName()); + for (String apiEnumPackageName : apiConfigEnumPackageNames) { apiEnumClassList.addAll(EnumTestHelper.getAllEnumsFromPackage(apiEnumPackageName)); } + // get the shared enums + ArrayList apiSharedEnumPackageNames = EnumTestHelper.findPackageNamesStartingWith(DhApiSharedEnumAssembly.class.getPackage().getName()); + for (String apiEnumPackageName : apiSharedEnumPackageNames) + { + apiEnumClassList.addAll(EnumTestHelper.getAllEnumsFromPackage(apiEnumPackageName)); + } + // get the list of core enums ArrayList>> coreEnumClassList = new ArrayList<>(); @@ -93,7 +103,7 @@ public class ApiEnumSyncTests // compare each API enum to its corresponding Core enum for (Class> apiEnumClass : apiEnumClassList) { - String coreEnumName = CoreEnumAssembly.ENUM_PREFIX + apiEnumClass.getSimpleName().substring(DhApiEnumAssembly.API_ENUM_PREFIX.length()); + String coreEnumName = CoreEnumAssembly.ENUM_PREFIX + apiEnumClass.getSimpleName().substring(DhApiSharedEnumAssembly.API_ENUM_PREFIX.length()); boolean coreEnumFound = false; // find the core enum to compare against