|
|
+ K$ b, a+ V4 w0 u0 y8 `6 @
行,这个怎么样. |' p1 L5 Z9 a, E% \" I7 @
- package com.xhg78999.mtrfac.render;. h! \ ?, m; F# A% w
9 n; W7 h. r/ j, g! |2 M$ U& r- import com.mojang.blaze3d.vertex.PoseStack;
4 {6 o( j5 n5 K5 o; L) m - import com.mojang.blaze3d.vertex.VertexConsumer;
, X* K" D5 O9 J! q! v2 g - import net.minecraft.client.renderer.RenderType;/ k& M% O7 V( Z$ y- N7 R% ~/ |
- import net.minecraft.resources.ResourceLocation;
v4 s. y+ V: @: S' E& o
" O9 u2 L" c/ W+ W% t- import java.util.*;; L4 O, E: X$ F
- , v2 w, g* U7 F: g* @
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(; B7 a( p3 P: J; R4 K
- # E( A/ ~/ ]! o: U
- public class LineRender{
2 @/ b) N6 Z* n( l% {4 z - private final PoseStack pose;
; K0 F! T: x' U - private final MultiBufferSource source; c N. a6 d7 S% ]' x6 H
- private static final Map<String, RenderType> CACHE_A = new HashMap<>();. [) ^0 U J( @/ D" {
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();0 A5 L* I+ [" I) _) B$ n! I& p. }2 m
3 A. e1 H8 J4 c
8 r8 R4 J0 M5 b' `- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
+ A( T ]% c3 @ - if(x1 == x2 && y1 == y2 && z1 == z2){
; L) a/ `: R: x - return;1 R7 W& B! _+ D
- }& f" k; U b) t) e+ m: C
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
9 e* w# q% `. m" K/ V1 n - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
* T7 A4 B4 {" T+ R4 M6 d' i( L - }! m7 p# i, O8 Q* t; x
- pose.pushPose();
6 b, U R4 Z4 ?. x, W, p - final int newLight = convertLight(6);, Q, ]7 T; B" L* M; w
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
4 {- D; A. H, Q0 ~ - final float lineHeightSmall = (y2 - y1);
) h3 r5 R/ D I8 h2 T - this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);
0 j1 B/ I! u V1 `8 Y, o - pose.popPose();
8 H9 k/ s1 H3 `: z: j - }5 ]6 @5 z1 c: o/ o% _% Z& [7 i5 i
# {- \( o& {% S0 f* s- private RenderType getLayers(String texture, int light) {
$ y: y: H( }( Q0 _7 W8 H7 e - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
6 Z& l1 S: \0 i - }
8 \" q8 F' P0 F% f2 ]5 b6 U
) s6 Q# K; m$ U5 B4 b. s+ q0 r) S- private RenderType getLightTexture(ResourceLocation texture) {
9 M$ W! c m' }" r7 ? - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);5 Y6 r9 U: I6 r) T( [! J3 f
- }
4 O% ]% s$ H/ F) i. T - ' e' z A0 b) o. V- q: d0 U2 O
- private RenderType getTexture(ResourceLocation texture) {, N# n4 q/ O, v! ?8 g _8 {, W
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);* z1 G- s4 t% P' h6 {
- }
( B7 N% P0 S, e - 9 i4 H2 W1 F( W
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
+ C; n0 Q [0 N: P1 c - if (cache.containsKey(identifier)) {4 t4 l t% K2 u
- return cache.get(identifier);
- j$ [) Z& |$ [ - } else {
( a) U5 m' w! _% E/ @0 x; X6 s - final RenderType renderLayer = supplier.get();
4 i" M( j( G8 t5 P/ f; p - cache.put(identifier, renderLayer);# {) P2 I- G* e8 u. S8 I, o
- return renderLayer;
9 F+ F+ s7 v1 A9 ?$ g - }
1 u i" E( w- o: C3 u/ o& t/ I6 X - }
7 v* o- |# ?, }, X - }
复制代码 |
|