|
|
- S; r8 a( T% A7 l* S5 J行,这个怎么样! g1 ?( B% n J6 @, D+ X/ j
- package com.xhg78999.mtrfac.render;3 q E: V' k) B3 {7 c! i/ G; B
- # J3 K3 [& W+ b
- import com.mojang.blaze3d.vertex.PoseStack;) d; p* q! I' g
- import com.mojang.blaze3d.vertex.VertexConsumer;) }; J+ ~; E: w2 Y
- import net.minecraft.client.renderer.RenderType;
7 T0 d1 R5 m- V! I& O - import net.minecraft.resources.ResourceLocation;- Z4 Z9 |8 B1 V/ D. r) t9 c
- . V5 e0 ?# {) a& P! _
- import java.util.*;
) }) V) d4 x! U0 y5 f* `0 N - 3 q7 a2 k3 _5 H2 ~1 C
- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :( w* `' f! I! T
- 2 H/ Z7 c* Y# S4 w; O H% y
- public class LineRender{7 z0 A0 [2 f; l- j' T) m& ^# [
- private final PoseStack pose;
+ \2 ^5 N- l1 m - private final MultiBufferSource source;
% y( Z/ \. z$ \- a2 @, D: P - private static final Map<String, RenderType> CACHE_A = new HashMap<>();
% p) Q9 D& c& e: [6 H) x2 c9 H+ [6 D - private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" a+ h/ ?$ u' T6 ]" r
' n o% n7 W+ v; z- z, L
" x Q* z0 H3 Z- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){7 E0 L+ [ @" ?& D# w$ |
- if(x1 == x2 && y1 == y2 && z1 == z2){
; }0 {4 O$ H! g) k7 T; [+ A K& i3 X - return;: S" R- k1 y6 u/ W }
- }4 P6 T4 A2 N" J/ T5 c5 M
- if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){
2 R7 ]9 v8 R9 G; T* m& f* L* y+ l - System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");7 b; I3 f/ m# ~ o$ W
- } ^2 T x( \+ G: R8 c% p1 H! s
- pose.pushPose();
' |$ N$ G- l* t K1 e7 ~ - final int newLight = convertLight(6);: D& O! h8 W+ K- Y; g& [
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));2 ~' X" W' v4 {" m
- final float lineHeightSmall = (y2 - y1);' g! S& U8 d6 J% r" q' r
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);! s" h9 c# _" [; _2 A' P7 d
- pose.popPose();
$ ?1 d* |$ ~9 ?9 O" j4 J - }+ [5 z% e' A* W8 E% f) m9 V
, P# M6 g! \( M0 [- private RenderType getLayers(String texture, int light) {$ R" m) z* [# A. _- d( Y4 @
- return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));* ~9 C7 I: f& b' Y) {
- }
: U0 h% \& A* ~
4 o, ?- K9 M# c- private RenderType getLightTexture(ResourceLocation texture) {' \5 F- h3 g% x
- return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);
7 u0 {& @2 K/ ~% {2 G/ p7 u - }, k1 M( ~: j1 X% J
& ~% D1 v7 H, ~- private RenderType getTexture(ResourceLocation texture) {& R2 A( i/ A+ _) v; ]% G
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);# P, p; P# N3 k
- }4 }- e$ w5 m+ i: T1 d7 e
2 _- U1 }5 v% Q7 l5 I- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {
8 U% C2 b' p8 d V# ` - if (cache.containsKey(identifier)) {
! P3 I- j3 y, s; q8 B# K+ f& A - return cache.get(identifier);9 C B$ s- F& s" n
- } else {7 i' n7 y2 f" b: }8 k" V
- final RenderType renderLayer = supplier.get();* c: a/ j8 o% P
- cache.put(identifier, renderLayer);
! S% h8 P2 p9 I/ x' t - return renderLayer;
$ D4 W' d' L" L a - }! a0 g" f! [6 S4 ^0 h
- }+ x7 g3 Z. B9 d7 H' p
- }
复制代码 |
|