|
2 | 2 |
|
3 | 3 | import org.joml.Matrix4f;
|
4 | 4 |
|
5 |
| -import com.mojang.blaze3d.systems.RenderSystem; |
6 |
| -import net.minecraft.block.Blocks; |
7 | 5 | import net.minecraft.client.MinecraftClient;
|
8 |
| -import net.minecraft.client.gl.GlUsage; |
9 |
| -import net.minecraft.client.gl.ShaderPipelines; |
10 | 6 | import net.minecraft.client.render.*;
|
11 | 7 | import net.minecraft.entity.Entity;
|
12 |
| -import net.minecraft.item.BlockItem; |
13 |
| -import net.minecraft.item.Item; |
14 |
| -import net.minecraft.util.math.Vec3d; |
15 | 8 | import net.minecraft.util.profiler.Profiler;
|
16 | 9 |
|
17 |
| -import fi.dy.masa.malilib.render.MaLiLibPipelines; |
18 |
| -import fi.dy.masa.malilib.render.RenderContext; |
19 |
| -import fi.dy.masa.malilib.render.RenderUtils; |
20 | 10 | import fi.dy.masa.malilib.util.EntityUtils;
|
21 |
| -import fi.dy.masa.malilib.util.data.Color4f; |
22 |
| -import fi.dy.masa.minihud.config.RendererToggle; |
23 | 11 |
|
24 | 12 | public class OverlayRenderer
|
25 | 13 | {
|
@@ -56,97 +44,7 @@ public static void renderOverlays(Matrix4f matrix4f, Matrix4f projMatrix, Minecr
|
56 | 44 | }
|
57 | 45 | }
|
58 | 46 |
|
59 |
| - if (RendererToggle.OVERLAY_BEACON_RANGE.getBooleanValue()) |
60 |
| - { |
61 |
| - profiler.push("BeaconRangeHeldItem"); |
62 |
| - renderBeaconBoxForPlayerIfHoldingItem(entity, mc); |
63 |
| - profiler.pop(); |
64 |
| - } |
65 |
| - |
66 |
| - RenderContainer.INSTANCE.render(entity, matrix4f, projMatrix, mc, camera, profiler); |
67 |
| - } |
68 |
| - |
69 |
| - |
70 |
| - public static void renderBeaconBoxForPlayerIfHoldingItem(Entity entity, MinecraftClient mc) |
71 |
| - { |
72 |
| - Item item = mc.player.getMainHandStack().getItem(); |
73 |
| - |
74 |
| - if (item instanceof BlockItem && ((BlockItem) item).getBlock() == Blocks.BEACON) |
75 |
| - { |
76 |
| - renderBeaconBoxForPlayer(entity, mc); |
77 |
| - return; |
78 |
| - } |
79 |
| - |
80 |
| - item = mc.player.getMainHandStack().getItem(); |
81 |
| - |
82 |
| - if (item instanceof BlockItem && ((BlockItem) item).getBlock() == Blocks.BEACON) |
83 |
| - { |
84 |
| - renderBeaconBoxForPlayer(entity, mc); |
85 |
| - } |
86 |
| - } |
87 |
| - |
88 |
| - private static void renderBeaconBoxForPlayer(Entity entity, MinecraftClient mc) |
89 |
| - { |
90 |
| - Vec3d cameraPos = mc.gameRenderer.getCamera().getPos(); |
91 |
| - double x = Math.floor(entity.getX()) - cameraPos.x; |
92 |
| - double y = Math.floor(entity.getY()) - cameraPos.y; |
93 |
| - double z = Math.floor(entity.getZ()) - cameraPos.z; |
94 |
| - // Use the slot number as the level if sneaking |
95 |
| - int level = mc.player.isSneaking() ? Math.min(4, mc.player.getInventory().getSelectedSlot() + 1) : 4; |
96 |
| - float range = level * 10 + 10; |
97 |
| - float minX = (float) (x - range); |
98 |
| - float minY = (float) (y - range); |
99 |
| - float minZ = (float) (z - range); |
100 |
| - float maxX = (float) (x + range + 1); |
101 |
| - float maxY = (float) (y + 4); |
102 |
| - float maxZ = (float) (z + range + 1); |
103 |
| - Color4f color = OverlayRendererBeaconRange.getColorForLevel(level); |
104 |
| - |
105 |
| - /* |
106 |
| - RenderSystem.disableCull(); |
107 |
| - RenderSystem.enableDepthTest(); |
108 |
| - RenderSystem.depthMask(false); |
109 |
| - RenderSystem.polygonOffset(-3f, -3f); |
110 |
| - RenderSystem.enablePolygonOffset(); |
111 |
| - */ |
112 |
| - fi.dy.masa.malilib.render.RenderUtils.blend(true); |
113 |
| - fi.dy.masa.malilib.render.RenderUtils.color(1f, 1f, 1f, 1f); |
114 |
| - |
115 |
| - // RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); |
116 |
| - // ShaderPipelines.DEBUG_LINE_STRIP |
117 |
| - RenderContext ctx = new RenderContext(() -> "", VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS, GlUsage.STATIC_WRITE); |
118 |
| - ctx.setShader(MaLiLibPipelines.POSITION_COLOR_SIMPLE); |
119 |
| - BufferBuilder buffer = ctx.getBuilder(); |
120 |
| - |
121 |
| - fi.dy.masa.malilib.render.RenderUtils.drawBoxAllSidesBatchedQuads(minX, minY, minZ, maxX, maxY, maxZ, Color4f.fromColor(color.intValue, 0.3f), buffer); |
122 |
| - |
123 |
| - try |
124 |
| - { |
125 |
| - ctx.drawColor(buffer.endNullable()); |
126 |
| - ctx.reset(); |
127 |
| - } |
128 |
| - catch (Exception ignored) { } |
129 |
| - |
130 |
| - buffer = ctx.startNoShader(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.DEBUG_LINES); |
131 |
| - ctx.setShader(MaLiLibPipelines.POSITION_COLOR_SIMPLE); |
132 |
| - |
133 |
| - //buffer = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); |
134 |
| - |
135 |
| - fi.dy.masa.malilib.render.RenderUtils.drawBoxAllEdgesBatchedLines(minX, minY, minZ, maxX, maxY, maxZ, Color4f.fromColor(color.intValue, 1f), buffer); |
136 |
| - |
137 |
| - try |
138 |
| - { |
139 |
| - ctx.drawColor(buffer.endNullable()); |
140 |
| - ctx.close(); |
141 |
| - } |
142 |
| - catch (Exception ignored) { } |
143 |
| - |
144 |
| - /* |
145 |
| - RenderSystem.polygonOffset(0f, 0f); |
146 |
| - RenderSystem.disablePolygonOffset(); |
147 |
| - RenderSystem.enableCull(); |
148 |
| - RenderSystem.disableBlend(); |
149 |
| - */ |
150 |
| - RenderUtils.blend(false); |
| 47 | + RenderContainer.INSTANCE.updateIfNeeded(camera.getPos(), entity, mc, profiler); |
| 48 | + RenderContainer.INSTANCE.render(camera, matrix4f, projMatrix, mc, profiler); |
151 | 49 | }
|
152 | 50 | }
|
0 commit comments