Skip to content

Commit

Permalink
fix: made waypoint beams work again
Browse files Browse the repository at this point in the history
Now using vanilla's beacon beam render type, no need for a custom one
  • Loading branch information
desht committed Jun 17, 2024
1 parent 7e1051d commit 88d1de6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.core.Holder;
Expand Down Expand Up @@ -99,6 +101,7 @@
public enum FTBChunksClient {
INSTANCE;

public static final ResourceLocation WAYPOINT_BEAM = FTBChunksAPI.rl("textures/waypoint_beam.png");
private static final ResourceLocation BUTTON_ID_MAP = FTBChunksAPI.rl("open_gui");
private static final ResourceLocation BUTTON_ID_CLAIM = FTBChunksAPI.rl("open_claim_gui");

Expand Down Expand Up @@ -843,7 +846,8 @@ public void renderWorldLast(PoseStack poseStack, Matrix4f projectionMatrix, Matr
poseStack.pushPose();
poseStack.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z);

VertexConsumer depthBuffer = mc.renderBuffers().bufferSource().getBuffer(FTBChunksRenderTypes.WAYPOINTS_DEPTH);
RenderType renderType = RenderType.beaconBeam(WAYPOINT_BEAM, true);
VertexConsumer depthBuffer = mc.renderBuffers().bufferSource().getBuffer(renderType);

float y1 = (float) (cameraPos.y + 30D);
float y2 = y1 + 70F;
Expand All @@ -856,7 +860,7 @@ public void renderWorldLast(PoseStack poseStack, Matrix4f projectionMatrix, Matr

poseStack.popPose();

mc.renderBuffers().bufferSource().endBatch(FTBChunksRenderTypes.WAYPOINTS_DEPTH);
mc.renderBuffers().bufferSource().endBatch(renderType);
}

private static void drawWaypointBeacon(PoseStack poseStack, Vec3 cameraPos, VertexConsumer depthBuffer, float y1, float y2, int yMin, WaypointIcon waypoint) {
Expand All @@ -876,15 +880,23 @@ private static void drawWaypointBeacon(PoseStack poseStack, Vec3 cameraPos, Vert

Matrix4f m = poseStack.last().pose();

depthBuffer.addVertex(m, -s, yMin, s).setColor(r, g, b, alpha).setUv(0F, 1F);
depthBuffer.addVertex(m, -s, y1, s).setColor(r, g, b, alpha).setUv(0F, 0F);
depthBuffer.addVertex(m, s, y1, -s).setColor(r, g, b, alpha).setUv(1F, 0F);
depthBuffer.addVertex(m, s, yMin, -s).setColor(r, g, b, alpha).setUv(1F, 1F);

depthBuffer.addVertex(m, -s, y1, s).setColor(r, g, b, alpha).setUv(0F, 1F);
depthBuffer.addVertex(m, -s, y2, s).setColor(r, g, b, 0).setUv(0F, 0F);
depthBuffer.addVertex(m, s, y2, -s).setColor(r, g, b, 0).setUv(1F, 0F);
depthBuffer.addVertex(m, s, y1, -s).setColor(r, g, b, alpha).setUv(1F, 1F);
depthBuffer.addVertex(m, -s, yMin, s).setColor(r, g, b, alpha).setUv(0F, 1F)
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);
depthBuffer.addVertex(m, -s, y1, s).setColor(r, g, b, alpha).setUv(0F, 0F)
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);
depthBuffer.addVertex(m, s, y1, -s).setColor(r, g, b, alpha).setUv(1F, 0F).
setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);
depthBuffer.addVertex(m, s, yMin, -s).setColor(r, g, b, alpha).setUv(1F, 1F)
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);

depthBuffer.addVertex(m, -s, y1, s).setColor(r, g, b, alpha).setUv(0F, 1F)
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);
depthBuffer.addVertex(m, -s, y2, s).setColor(r, g, b, 0).setUv(0F, 0F)
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);
depthBuffer.addVertex(m, s, y2, -s).setColor(r, g, b, 0).setUv(1F, 0F)
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);
depthBuffer.addVertex(m, s, y1, -s).setColor(r, g, b, alpha).setUv(1F, 1F)
.setOverlay(OverlayTexture.NO_OVERLAY).setLight(0xF000F0).setNormal(poseStack.last(), 0f, 1f, 0f);

poseStack.popPose();
}
Expand Down

This file was deleted.

0 comments on commit 88d1de6

Please sign in to comment.