|
|
9 A; i; J3 m/ y5 L3 j行,这个怎么样
; ^" k& \: o3 O- package com.xhg78999.mtrfac.render;
' L; P/ i. F9 T, n& S$ V. ` - s, B6 ^# Y: l9 ^/ i
- import com.mojang.blaze3d.vertex.PoseStack; N1 B$ ^7 x" Y. s) z% |9 F9 V/ W
- import com.mojang.blaze3d.vertex.VertexConsumer;0 U7 a) f" w# j
- import net.minecraft.client.renderer.RenderType;
& R3 z6 [& i; j3 ?. L1 | D - import net.minecraft.resources.ResourceLocation;& X! G Z9 B- a9 |
0 Z Q. W1 ~2 P! s9 q/ N- import java.util.*;* W, N5 k. b- Y
- `. Y& v& [# @: R& P- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
- d1 w+ Q6 ~8 m - 1 R7 \' `5 H4 Z5 u2 F; p
- public class LineRender{
+ X' V! L; u4 T. ]2 W' q - private final PoseStack pose;' e+ d# \7 ^2 f) o
- private final MultiBufferSource source;
( ~: g! u7 B0 H, b* p/ | - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
$ [! n( h( q4 W( k6 o - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();
8 ~/ O' u- @6 y3 F+ @ - 5 @2 v! P2 x8 e+ u! b6 Y, x' N
- & q- T9 R( J+ l8 t/ R7 ~
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
7 r8 j/ u; }- @) L6 \+ q3 y - if(x1 == x2 && y1 == y2 && z1 == z2){
) x, K8 ?, l& Q y7 a) P4 w - return;% m" b: l" x' x" X/ x
- }+ Z0 L) N) [; L6 d; V
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
n% H# j# e4 y! ^& N6 O - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
/ k8 f6 Z+ J) x- F - }" ^. I1 P7 [ g8 A1 n& ^! _
- pose.pushPose();
2 W8 H/ y. o9 \$ N+ E* X - final int newLight = convertLight(6);
; r* O, z& D3 _ P( T- k - final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
2 W( X/ ]7 M4 F9 E" c) B - final float lineHeightSmall = (y2 - y1);2 _- l7 d: E D/ F' v) |2 e% Q. d' B
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);( m6 e; ]% a6 d* q# h! q: Z7 L3 _* y
- pose.popPose();# `' [: p. [( S$ T, q9 g
- }
* b; j0 m+ v( S) i+ A - % Y+ Z2 L( a! V+ z) M o9 u) E0 h
- private RenderType getLayers(String texture, int light) {
! N8 R/ d& I* b' n) z3 { - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
; X. B; ]9 O. D - }
/ S$ T) ?3 E* k0 G/ ~; ~+ I. w
0 ?& ~( Q* M/ B9 p( Z2 E# R" y- private RenderType getLightTexture(ResourceLocation texture) {
! h2 i' w+ e4 V - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
- q r1 W: ^, p, N7 P - }
3 e: A$ n+ V/ @* O - 3 J4 ^. a/ g* U1 B5 Q- L3 `2 B
- private RenderType getTexture(ResourceLocation texture) {
! @. c4 Q/ ~3 M6 v# b3 W4 p( y0 l - return this.cache(texture, () -> entityCutout(texture), CACHE_B);5 @/ z% {3 V# r, f' B5 {7 t: Z
- }! o4 E0 a# ]; P/ J
- ) i9 x/ J# k1 K
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {( Z9 P3 i4 c; X7 J4 E- }
- if (cache.containsKey(identifier)) {6 o1 x! ^% Y5 b3 S2 J8 h6 X
- return cache.get(identifier);
, J+ S! B$ U0 N, t8 Z - } else {# v/ d4 l6 [4 w9 E' z# l" @
- final RenderType renderLayer = supplier.get();
' y+ }+ j5 F5 m) w1 `6 u1 } - cache.put(identifier, renderLayer);
7 `" J, [. l% n3 P, d& B/ @9 U - return renderLayer;
5 V# A7 ]: @& ?1 I# b8 s0 q! @ - }
0 U$ g: s% j; Q" U( T) l - }
- H: I1 } `% z0 {2 h: g" I, g9 G - }
复制代码 |
|