diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-26 12:32:51 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-26 12:32:51 +0200 |
commit | effd69e9f113c808dae5e51e2b55574886d0e230 (patch) | |
tree | 11cc6b5241a1937b2f76729468fec4e80d2b0552 /src/main/java/at | |
parent | 7fc421dc3e81d0cf60387516c74768db2bde9658 (diff) | |
download | skyhanni-effd69e9f113c808dae5e51e2b55574886d0e230.tar.gz skyhanni-effd69e9f113c808dae5e51e2b55574886d0e230.tar.bz2 skyhanni-effd69e9f113c808dae5e51e2b55574886d0e230.zip |
ugly workaround: duplicating the methods drawFilledBoundingBox draw3DLine with a variant before nea made the parkour changes
Diffstat (limited to 'src/main/java/at')
4 files changed, 237 insertions, 157 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt index c7d2605e6..2ee5ab31f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt @@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText -import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox +import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock import net.minecraft.client.Minecraft import net.minecraft.util.EnumParticleTypes @@ -120,12 +120,12 @@ class RiftWiltedBerberisHelper { val location = currentParticles.fixLocation(berberis) if (!moving) { - event.drawFilledBoundingBox(axisAlignedBB(location), Color.YELLOW, 0.7f) + event.drawFilledBoundingBox_nea(axisAlignedBB(location), Color.YELLOW, 0.7f) event.drawDynamicText(location.add(0, 1, 0), "§eWilted Berberis", 1.5, ignoreBlocks = false) } else { - event.drawFilledBoundingBox(axisAlignedBB(location), Color.WHITE, 0.5f) + event.drawFilledBoundingBox_nea(axisAlignedBB(location), Color.WHITE, 0.5f) previous?.fixLocation(berberis)?.let { - event.drawFilledBoundingBox(axisAlignedBB(it), Color.LIGHT_GRAY, 0.2f) + event.drawFilledBoundingBox_nea(axisAlignedBB(it), Color.LIGHT_GRAY, 0.2f) event.draw3DLine(it.add(0.5, 0.0, 0.5), location.add(0.5, 0.0, 0.5), Color.WHITE, 3, false) } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt index e7d229ca8..2fb009914 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.* -import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox +import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest @@ -74,7 +74,7 @@ class ParkourWaypointSaver { } else { for (location in locations) { val aabb = location.boundingToOffset(1.0, 1.0, 1.0).expandBlock() - event.drawFilledBoundingBox(aabb, LorenzColor.GREEN.toColor(), 1f) + event.drawFilledBoundingBox_nea(aabb, LorenzColor.GREEN.toColor(), 1f) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt index 410c29aca..6013dec6f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt @@ -4,9 +4,9 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.test.command.CopyErrorCommand import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils.toSingletonListOrEmpty -import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine_nea import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText -import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox +import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea import at.hannibal2.skyhanni.utils.RenderUtils.drawString import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock import at.hannibal2.skyhanni.utils.RenderUtils.outlineTopFace @@ -81,7 +81,7 @@ class ParkourHelper( val inProgressVec = getInProgressPair().toSingletonListOrEmpty() for ((prev, next) in locations.asSequence().withIndex().zipWithNext().drop(current) .take(lookAhead - 1) + inProgressVec) { - event.draw3DLine( + event.draw3DLine_nea( prev.value.offsetCenter(), next.value.offsetCenter(), colorForIndex(prev.index), @@ -95,12 +95,12 @@ class ParkourHelper( if (shortCut.from in nextShortcuts && shortCut.to in locations.indices) { val from = locations[shortCut.from].offsetCenter() val to = locations[shortCut.to].offsetCenter() - event.draw3DLine(from, to, Color.RED, 3, false) + event.draw3DLine_nea(from, to, Color.RED, 3, false) val textLocation = from.add(to.subtract(from).normalize()) event.drawDynamicText(textLocation.add(-0.5, 1.0, -0.5), "§cShortcut", 1.8) val aabb = axisAlignedBB(locations[shortCut.to]) - event.drawFilledBoundingBox(aabb, Color.RED, 1f) + event.drawFilledBoundingBox_nea(aabb, Color.RED, 1f) if (outline) event.outlineTopFace(aabb, 2, Color.BLACK, true) } @@ -112,10 +112,10 @@ class ParkourHelper( if (isMovingPlatform && showEverything) continue if (isMovingPlatform) { val aabb = axisAlignedBB(location).expandBlock() - event.drawFilledBoundingBox(aabb, colorForIndex(index), .6f) + event.drawFilledBoundingBox_nea(aabb, colorForIndex(index), .6f) } else { val aabb = axisAlignedBB(location) - event.drawFilledBoundingBox(aabb, colorForIndex(index), 1f) + event.drawFilledBoundingBox_nea(aabb, colorForIndex(index), 1f) if (outline) event.outlineTopFace(aabb, 2, Color.BLACK, true) } if (SkyHanniMod.feature.dev.waypoint.showPlatformNumber) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index c72e1f40e..80fa55ddc 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -86,117 +86,8 @@ object RenderUtils { GlStateManager.enableCull() } - fun getViewerPos(partialTicks: Float) = exactLocation(Minecraft.getMinecraft().renderViewEntity, partialTicks) - /** - * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0 - * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE - * @author Moulberry - * @author Mojang - */ - fun drawFilledBoundingBox( - aabb: AxisAlignedBB, - c: Color, - alphaMultiplier: Float = 1f, - /** - * If set to `true`, renders the box relative to the camera instead of relative to the world. - * If set to `false`, will be relativized to [RenderUtils.getViewerPos]. Setting this to `false` requires - * specifying [partialTicks]] - */ - renderRelativeToCamera: Boolean = true, - drawVerticalBarriers: Boolean = true, - partialTicks: Float = 0F, - ) { - GlStateManager.enableBlend() - GlStateManager.disableLighting() - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) - GlStateManager.disableTexture2D() - GlStateManager.disableCull() - val effectiveAABB = if (!renderRelativeToCamera) { - val vp = getViewerPos(partialTicks) - AxisAlignedBB( - aabb.minX - vp.x, aabb.minY - vp.y, aabb.minZ - vp.z, - aabb.maxX - vp.x, aabb.maxY - vp.y, aabb.maxZ - vp.z, - ) - } else { - aabb - } - val tessellator = Tessellator.getInstance() - val worldRenderer = tessellator.worldRenderer - - //vertical - if (drawVerticalBarriers) { - GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier) - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - with(effectiveAABB) { - worldRenderer.pos(minX, minY, minZ).endVertex() - worldRenderer.pos(maxX, minY, minZ).endVertex() - worldRenderer.pos(maxX, minY, maxZ).endVertex() - worldRenderer.pos(minX, minY, maxZ).endVertex() - } - tessellator.draw() - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - with(effectiveAABB) { - worldRenderer.pos(minX, maxY, maxZ).endVertex() - worldRenderer.pos(maxX, maxY, maxZ).endVertex() - worldRenderer.pos(maxX, maxY, minZ).endVertex() - worldRenderer.pos(minX, maxY, minZ).endVertex() - } - tessellator.draw() - } - GlStateManager.color( - c.red / 255f * 0.8f, - c.green / 255f * 0.8f, - c.blue / 255f * 0.8f, - c.alpha / 255f * alphaMultiplier - ) - - //x - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - with(effectiveAABB) { - worldRenderer.pos(minX, minY, maxZ).endVertex() - worldRenderer.pos(minX, maxY, maxZ).endVertex() - worldRenderer.pos(minX, maxY, minZ).endVertex() - worldRenderer.pos(minX, minY, minZ).endVertex() - } - tessellator.draw() - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - with(effectiveAABB) { - worldRenderer.pos(maxX, minY, minZ).endVertex() - worldRenderer.pos(maxX, maxY, minZ).endVertex() - worldRenderer.pos(maxX, maxY, maxZ).endVertex() - worldRenderer.pos(maxX, minY, maxZ).endVertex() - } - tessellator.draw() - GlStateManager.color( - c.red / 255f * 0.9f, - c.green / 255f * 0.9f, - c.blue / 255f * 0.9f, - c.alpha / 255f * alphaMultiplier - ) - //z - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - with(effectiveAABB) { - worldRenderer.pos(minX, maxY, minZ).endVertex() - worldRenderer.pos(maxX, maxY, minZ).endVertex() - worldRenderer.pos(maxX, minY, minZ).endVertex() - worldRenderer.pos(minX, minY, minZ).endVertex() - } - tessellator.draw() - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - with(effectiveAABB) { - worldRenderer.pos(minX, minY, maxZ).endVertex() - worldRenderer.pos(maxX, minY, maxZ).endVertex() - worldRenderer.pos(maxX, maxY, maxZ).endVertex() - worldRenderer.pos(minX, maxY, maxZ).endVertex() - } - tessellator.draw() - GlStateManager.enableTexture2D() - GlStateManager.enableCull() - GlStateManager.disableBlend() - } - fun AxisAlignedBB.expandBlock() = expand(0.0020000000949949026, 0.0020000000949949026, 0.0020000000949949026) /** @@ -547,8 +438,7 @@ object RenderUtils { GlStateManager.translate(getAbsX().toFloat(), (getAbsY() + offsetY).toFloat(), 0F) var offsetX = 0 for (any in line) { - val renderable = - Renderable.fromAny(any, itemScale = itemScale) ?: throw RuntimeException("Unknown render object: $any") + val renderable = Renderable.fromAny(any, itemScale = itemScale) ?: throw RuntimeException("Unknown render object: ${any}") renderable.render(getAbsX() + offsetX, getAbsY() + offsetY) offsetX += renderable.width @@ -625,7 +515,7 @@ object RenderUtils { GlStateManager.enableBlend() GlStateManager.depthFunc(GL11.GL_LEQUAL) GlStateManager.disableCull() - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) GlStateManager.enableAlpha() GlStateManager.disableTexture2D() color.bindColor() @@ -780,7 +670,125 @@ object RenderUtils { } } - fun RenderWorldLastEvent.drawFilledBoundingBox( + fun RenderWorldLastEvent.draw3DLine(p1: LorenzVec, p2: LorenzVec, color: Color, lineWidth: Int, depth: Boolean) { + GlStateManager.disableDepth() + GlStateManager.disableCull() + + val render = Minecraft.getMinecraft().renderViewEntity + val worldRenderer = Tessellator.getInstance().worldRenderer + val realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks + val realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks + val realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks + GlStateManager.pushMatrix() + GlStateManager.translate(-realX, -realY, -realZ) + GlStateManager.disableTexture2D() + GlStateManager.enableBlend() + GlStateManager.disableAlpha() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GL11.glLineWidth(lineWidth.toFloat()) + if (!depth) { + GL11.glDisable(GL11.GL_DEPTH_TEST) + GlStateManager.depthMask(false) + } + GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f) + worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION) + worldRenderer.pos(p1.x, p1.y, p1.z).endVertex() + worldRenderer.pos(p2.x, p2.y, p2.z).endVertex() + Tessellator.getInstance().draw() + GlStateManager.translate(realX, realY, realZ) + if (!depth) { + GL11.glEnable(GL11.GL_DEPTH_TEST) + GlStateManager.depthMask(true) + } + GlStateManager.disableBlend() + GlStateManager.enableAlpha() + GlStateManager.enableTexture2D() + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f) + GlStateManager.popMatrix() + GlStateManager.disableLighting() + GlStateManager.enableDepth() + } + + fun RenderWorldLastEvent.exactLocation(entity: Entity): LorenzVec { + return exactLocation(entity, partialTicks) + } + + fun exactLocation(entity: Entity, partialTicks: Float): LorenzVec { + val x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks + val y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks + val z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks + return LorenzVec(x, y, z) + } + + + + fun drawFilledBoundingBox(aabb: AxisAlignedBB, c: Color, alphaMultiplier: Float = 1f) { + GlStateManager.enableBlend() + GlStateManager.disableLighting() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.disableTexture2D() + val tessellator = Tessellator.getInstance() + val worldRenderer = tessellator.worldRenderer + GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier) + + //vertical + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex() + tessellator.draw() + GlStateManager.color( + c.red / 255f * 0.8f, + c.green / 255f * 0.8f, + c.blue / 255f * 0.8f, + c.alpha / 255f * alphaMultiplier + ) + + //x + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex() + tessellator.draw() + GlStateManager.color( + c.red / 255f * 0.9f, + c.green / 255f * 0.9f, + c.blue / 255f * 0.9f, + c.alpha / 255f * alphaMultiplier + ) + //z + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex() + worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex() + worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex() + tessellator.draw() + GlStateManager.enableTexture2D() + GlStateManager.disableBlend() + } + + // TODO nea please merge with 'drawFilledBoundingBox' + fun RenderWorldLastEvent.drawFilledBoundingBox_nea( aabb: AxisAlignedBB, c: Color, alphaMultiplier: Float = 1f, @@ -791,7 +799,97 @@ object RenderUtils { renderRelativeToCamera: Boolean = false, drawVerticalBarriers: Boolean = true ) { - drawFilledBoundingBox(aabb, c, alphaMultiplier, renderRelativeToCamera, drawVerticalBarriers, partialTicks) + drawFilledBoundingBox_nea(aabb, c, alphaMultiplier, renderRelativeToCamera, drawVerticalBarriers, partialTicks) + } + + fun drawFilledBoundingBox_nea( + aabb: AxisAlignedBB, + c: Color, + alphaMultiplier: Float = 1f, + /** + * If set to `true`, renders the box relative to the camera instead of relative to the world. + * If set to `false`, will be relativized to [RenderUtils.getViewerPos]. Setting this to `false` requires + * specifying [partialTicks]] + */ + renderRelativeToCamera: Boolean = true, + drawVerticalBarriers: Boolean = true, + partialTicks: Float = 0F, + ) { + GlStateManager.enableBlend() + GlStateManager.disableLighting() + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) + GlStateManager.disableTexture2D() + GlStateManager.disableCull() + val effectiveAABB = if (!renderRelativeToCamera) { + val vp = getViewerPos(partialTicks) + AxisAlignedBB( + aabb.minX - vp.x, aabb.minY - vp.y, aabb.minZ - vp.z, + aabb.maxX - vp.x, aabb.maxY - vp.y, aabb.maxZ - vp.z, + ) + } else { + aabb + } + val tessellator = Tessellator.getInstance() + val worldRenderer = tessellator.worldRenderer + + //vertical + if (drawVerticalBarriers) { + GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier) + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + tessellator.draw() + } + GlStateManager.color( + c.red / 255f * 0.8f, + c.green / 255f * 0.8f, + c.blue / 255f * 0.8f, + c.alpha / 255f * alphaMultiplier + ) + + //x + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + tessellator.draw() + GlStateManager.color( + c.red / 255f * 0.9f, + c.green / 255f * 0.9f, + c.blue / 255f * 0.9f, + c.alpha / 255f * alphaMultiplier + ) + //z + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + tessellator.draw() + GlStateManager.enableTexture2D() + GlStateManager.enableCull() + GlStateManager.disableBlend() } fun RenderWorldLastEvent.outlineTopFace(boundingBox: AxisAlignedBB, lineWidth: Int, colour: Color, depth: Boolean) { @@ -805,65 +903,47 @@ object RenderUtils { this.draw3DLine(cornerFour, cornerOne, colour, lineWidth, depth) } - fun RenderWorldLastEvent.draw3DLine( + // TODO nea please merge with 'draw3DLine' + fun RenderWorldLastEvent.draw3DLine_nea( p1: LorenzVec, p2: LorenzVec, color: Color, lineWidth: Int, depth: Boolean, targetColor: Color? = null, seeThroughBlocks: Boolean = true ) { + GlStateManager.disableDepth() + GlStateManager.disableCull() + val render = Minecraft.getMinecraft().renderViewEntity val worldRenderer = Tessellator.getInstance().worldRenderer val realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks val realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks val realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks GlStateManager.pushMatrix() - if (!seeThroughBlocks) { - GlStateManager.disableDepth() - } - GlStateManager.disableCull() - GlStateManager.disableLighting() GlStateManager.translate(-realX, -realY, -realZ) GlStateManager.disableTexture2D() GlStateManager.enableBlend() GlStateManager.disableAlpha() - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) GL11.glLineWidth(lineWidth.toFloat()) if (!depth) { GL11.glDisable(GL11.GL_DEPTH_TEST) GlStateManager.depthMask(false) } - GlStateManager.color(1f, 1f, 1f, 1f) - if (targetColor != null) - GlStateManager.shadeModel(GL11.GL_SMOOTH) - worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR) - worldRenderer.pos(p1.x, p1.y, p1.z).color(color.red, color.green, color.blue, color.alpha).endVertex() - val secondColor = targetColor ?: color - worldRenderer.pos(p2.x, p2.y, p2.z) - .color(secondColor.red, secondColor.green, secondColor.blue, secondColor.alpha).endVertex() + GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f) + worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION) + worldRenderer.pos(p1.x, p1.y, p1.z).endVertex() + worldRenderer.pos(p2.x, p2.y, p2.z).endVertex() Tessellator.getInstance().draw() + GlStateManager.translate(realX, realY, realZ) if (!depth) { GL11.glEnable(GL11.GL_DEPTH_TEST) GlStateManager.depthMask(true) } - GlStateManager.shadeModel(GL11.GL_FLAT) GlStateManager.disableBlend() GlStateManager.enableAlpha() GlStateManager.enableTexture2D() GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f) GlStateManager.popMatrix() GlStateManager.disableLighting() - if (!seeThroughBlocks) { - GlStateManager.enableDepth() - } - } - - fun RenderWorldLastEvent.exactLocation(entity: Entity): LorenzVec { - return exactLocation(entity, partialTicks) - } - - fun exactLocation(entity: Entity, partialTicks: Float): LorenzVec { - val x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks - val y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks - val z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks - return LorenzVec(x, y, z) + GlStateManager.enableDepth() } fun chromaColor( |