diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-11 09:26:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-11 09:26:49 +0200 |
commit | 974cc48b355ff020cbb17dc036730616b159b855 (patch) | |
tree | a02e270a44c3089724a2a9b8680cb596f3e43814 /src/main/java/at/hannibal2/skyhanni/utils | |
parent | e24f16df0e8f856d6ec6f81d7707841d27cd9ee8 (diff) | |
download | skyhanni-974cc48b355ff020cbb17dc036730616b159b855.tar.gz skyhanni-974cc48b355ff020cbb17dc036730616b159b855.tar.bz2 skyhanni-974cc48b355ff020cbb17dc036730616b159b855.zip |
Backend: code duplication in AxisAlignedBB.getCorners (#1756)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 10 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 05ea212b1..d07f3b149 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -27,6 +27,7 @@ import net.minecraft.client.gui.inventory.GuiEditSign import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.SharedMonsterAttributes import net.minecraft.launchwrapper.Launch +import net.minecraft.util.AxisAlignedBB import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.FMLCommonHandler import java.text.DecimalFormat @@ -362,4 +363,13 @@ object LorenzUtils { || inAdvancedMiningIsland() fun isBetaVersion() = UpdateManager.isCurrentlyBeta() + + fun AxisAlignedBB.getCorners(y: Double): List<LorenzVec> { + val cornerOne = LorenzVec(minX, y, minZ) + val cornerTwo = LorenzVec(minX, y, maxZ) + val cornerThree = LorenzVec(maxX, y, maxZ) + val cornerFour = LorenzVec(maxX, y, minZ) + + return listOf(cornerOne, cornerTwo, cornerThree, cornerFour) + } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index fb97a8357..7d37953b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.zipWithNext3 import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils.getCorners import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned import at.hannibal2.skyhanni.utils.shader.ShaderManager @@ -1508,10 +1509,7 @@ object RenderUtils { colour: Color, depth: Boolean, ) { - val cornerOne = LorenzVec(boundingBox.minX, boundingBox.maxY, boundingBox.minZ) - val cornerTwo = LorenzVec(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ) - val cornerThree = LorenzVec(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) - val cornerFour = LorenzVec(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ) + val (cornerOne, cornerTwo, cornerThree, cornerFour, ) = boundingBox.getCorners(boundingBox.maxY) this.draw3DLine(cornerOne, cornerTwo, colour, lineWidth, depth) this.draw3DLine(cornerTwo, cornerThree, colour, lineWidth, depth) this.draw3DLine(cornerThree, cornerFour, colour, lineWidth, depth) |