|
|
3 V# U, A( T+ K( W3 r6 {: A) |行,这个怎么样
! p* p* ~/ F8 { I* ^7 N" J- package com.xhg78999.mtrfac.render;
, J, m! K' ?% m$ }3 i9 P( Q - % F0 H @) T- C$ H
- import com.mojang.blaze3d.vertex.PoseStack;
, p0 [6 @$ v& n3 V, A# h& p- a1 k! L7 Y0 r - import com.mojang.blaze3d.vertex.VertexConsumer;
; A9 z( o- a# C1 W) M1 c. J# _! H6 V - import net.minecraft.client.renderer.RenderType;0 P; S* p Y1 C3 u0 Y3 h
- import net.minecraft.resources.ResourceLocation;& p9 W0 `% w- a1 R0 C$ K! E! J
3 N. ?$ `- G% ^3 }, u8 i1 E- import java.util.*;
" x1 l9 v8 k) p% {. V: m+ Y: N+ L# {
" u3 d6 |; M3 q: q- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(* I: y# M8 l$ R7 S
+ s: y; f- v! k: u/ i: P) O- public class LineRender{2 B# E$ h4 C9 H6 ^
- private final PoseStack pose;: O8 p/ j" ^: d; M4 i
- private final MultiBufferSource source;
+ x7 L) h% |9 Q, n& r" O& I7 X - private static final Map<String, RenderType> CACHE_A = new HashMap<>();$ s3 O4 I d- E9 _
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>(); [, V8 ~% t. F2 o P$ i1 O( g
5 I3 u+ u$ m% B- $ Y' `/ n H) k) X' C6 o6 A! f
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
: I* }3 f: l# X2 q - if(x1 == x2 && y1 == y2 && z1 == z2){' j) E( J- [/ |9 T8 F- O: r2 `+ p
- return;
+ T! }" K: ~5 X$ `' r - }# A, p8 c& B. b! a- B- k% r
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
, u- c' `9 K( }+ d/ O - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
8 n* a& T$ E# n0 i - }$ [) Z" W8 a" s( s' y& N% g# S
- pose.pushPose();
4 d j& e& C& O - final int newLight = convertLight(6);" o6 ?: f1 c; K9 [ E* C! p
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
- I8 c% c0 Q* A - final float lineHeightSmall = (y2 - y1);- m: ]) A9 M2 e" h- F7 B$ e
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);# g- r1 m+ B) T% n+ ~
- pose.popPose();
( v m3 _6 v9 R B/ K - }
9 N! y& G! [& e1 H9 m
; k8 ^1 I3 u0 X- private RenderType getLayers(String texture, int light) {
2 Y) D1 a0 C/ V+ T3 K - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));* s% J& g, d; r7 F! j5 `* q
- }$ C5 }1 r) k6 `0 [ G4 s( s
- 5 O; [9 b) i1 l! ]5 C9 J! D& s' E2 a
- private RenderType getLightTexture(ResourceLocation texture) {
; c# m r7 d- w! N9 Z* P - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" S @2 C3 F2 x% Q
- }
0 x% I: i* _, T2 L+ Z7 w: u; S
! r) [( H2 \( u; u" g: Z# \- private RenderType getTexture(ResourceLocation texture) {; p6 g5 c$ P& @: ~3 U( F
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);
, M" L5 ] f' \8 U4 K6 x9 C - }; l: n Y3 R6 n, E! f
- : T1 ^" Z2 Y3 ~& M; q/ F: s
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {& {4 B& E6 e* [$ ]4 k0 U6 H; V- u5 ]
- if (cache.containsKey(identifier)) {& o! M) u) |; ^8 J
- return cache.get(identifier);7 D$ r/ t6 E% k$ D2 E4 o
- } else {& s+ C0 l$ m$ R' O _4 h+ F7 Y
- final RenderType renderLayer = supplier.get();
. k$ O1 S, f2 ]0 T7 G% ~ - cache.put(identifier, renderLayer);
+ U" \% ^2 L0 M& Q - return renderLayer;5 \6 Q5 s1 W0 o1 K6 {
- }% @/ _) d1 l7 y. e9 m( i0 J
- }/ `: X8 Y/ b' K# K f' W( R
- }
复制代码 |
|