Skip to content

Commit

Permalink
Fixup freecam + waypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
GT3CH1 committed Sep 7, 2024
1 parent 8fc48fc commit 9ba8172
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
12 changes: 11 additions & 1 deletion src/main/kotlin/com/peasenet/mods/misc/ModFreeCam.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ModFreeCam : MiscMod(
val bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
val e = fake!!
var box = e.boundingBox
val lerped = MathUtils.lerp(
var lerped = MathUtils.lerp(
partialTicks,
e.pos,
Vec3d(e.lastRenderX, e.lastRenderY, e.lastRenderZ),
Expand All @@ -160,6 +160,16 @@ class ModFreeCam : MiscMod(
Settings.getConfig<EspConfig>("esp").playerColor,
Settings.getConfig<EspConfig>("esp").alpha
)
val regionVec = RenderUtils.getCameraRegionPos().toVec3d();
val start = RenderUtils.getLookVec(partialTicks).add(RenderUtils.getCameraPos()).subtract(regionVec);
RenderUtils.drawSingleLine(
bufferBuilder,
entry,
start,
e.boundingBox.center.subtract(regionVec),
Settings.getConfig<EspConfig>("esp").playerColor,
Settings.getConfig<EspConfig>("esp").alpha
)
val end = bufferBuilder.end()
BufferRenderer.drawWithGlobalProgram(end)
RenderUtils.cleanupRender(matrixStack)
Expand Down
39 changes: 24 additions & 15 deletions src/main/kotlin/com/peasenet/mods/render/ModWaypoint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,23 @@ import com.peasenet.util.Dimension
import com.peasenet.util.PlayerUtils
import com.peasenet.util.RenderUtils
import com.peasenet.util.event.data.CameraBob
import com.peasenet.util.event.data.EntityRender
import com.peasenet.util.listeners.CameraBobListener
import com.peasenet.util.listeners.EntityRenderListener
import com.peasenet.util.listeners.RenderListener
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gl.VertexBuffer
import net.minecraft.client.render.BufferRenderer
import net.minecraft.client.render.GameRenderer
import net.minecraft.client.render.VertexFormat
import net.minecraft.client.render.VertexFormats
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.Text
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
import java.util.function.Function

/**
* @author gt3ch1
* @version 03-02-2023
* Creates a new mod to control waypoints.
* @author gt3ch1
* @version 09-06-2024
* @since 03-02-2023
*/
class ModWaypoint : RenderMod(
"Waypoints",
Expand All @@ -63,20 +62,13 @@ class ModWaypoint : RenderMod(
ModCategory.WAYPOINTS
), RenderListener, CameraBobListener {

private var vertexBuffer: VertexBuffer? = null

init {

reloadSettings()

}


override fun onEnable() {
super.onEnable()
vertexBuffer = VertexBuffer(VertexBuffer.Usage.STATIC)
val bb = Box(-0.5, 0.0, -0.5, 0.5, 1.0, 0.5)
RenderUtils.drawOutlinedBox(bb, vertexBuffer!!)
em.subscribe(RenderListener::class.java, this)
em.subscribe(CameraBobListener::class.java, this)
for (w in Settings.getConfig<WaypointConfig>("waypoints").getLocations()) {
Expand Down Expand Up @@ -136,7 +128,11 @@ class ModWaypoint : RenderMod(
val playerDimension = Dimension.fromValue(MinecraftClient.getInstance().player!!.world.dimension.effects.path!!)

RenderUtils.setupRender(matrixStack)
RenderSystem.setShader(GameRenderer::getPositionProgram);
RenderSystem.setShader(GameRenderer::getPositionColorProgram);

val entry = matrixStack.peek().positionMatrix
val tessellator = RenderSystem.renderThreadTesselator()
val bufferBuilder = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
Settings.getConfig<WaypointConfig>("waypoints").getLocations().stream().filter { obj: Waypoint ->
obj.canRender(playerDimension)
}.forEach { w: Waypoint ->
Expand All @@ -150,8 +146,21 @@ class ModWaypoint : RenderMod(
pos.z
)
if (w.isEspEnabled)
RenderUtils.drawOutlinedBox(bb, vertexBuffer!!, matrixStack, w.color!!)
RenderUtils.drawOutlinedBox(bb, bufferBuilder, entry, w.color!!)
if (w.isTracerEnabled) {
val regionVec = RenderUtils.getCameraRegionPos().toVec3d();
val start = RenderUtils.getLookVec(partialTicks).add(RenderUtils.getCameraPos()).subtract(regionVec);
RenderUtils.drawSingleLine(
bufferBuilder,
entry,
start,
bb.center,
w.color!!
)
}
}
val end = bufferBuilder.end()
BufferRenderer.drawWithGlobalProgram(end)
RenderUtils.resetRenderSystem()
}

Expand Down

0 comments on commit 9ba8172

Please sign in to comment.