|
|
: o7 M9 c" a& J; M: W行,这个怎么样
( j: j9 P" z6 L, X7 ?- package com.xhg78999.mtrfac.render;. p+ j& Z* P, g2 p0 z! l
" Q. ]% K+ ?, V% x- import com.mojang.blaze3d.vertex.PoseStack;
, t/ p3 r4 r- M8 V9 V7 J) L) N - import com.mojang.blaze3d.vertex.VertexConsumer;
, g7 y: x5 e" r" b - import net.minecraft.client.renderer.RenderType;
- C+ k; T. Q1 `' P0 J" D( I* {, l - import net.minecraft.resources.ResourceLocation;
2 O1 u6 N6 s! c$ u( `
+ y# `9 G* o: k- import java.util.*;; g2 r, L7 ~1 X
0 ]% H9 Q( n' e' a- // Render!Vertex!Textures!Aaaaaaaaaaaaaaaaaaaaa I crashed! :(
3 H5 u( o4 h2 [ - 3 p* ~, [/ ~5 r. o
- public class LineRender{
/ }- m3 S1 y" o" R1 h - private final PoseStack pose;
$ ?( P* i3 a' v! h+ } - private final MultiBufferSource source;
' [% }$ u& L# h' P' Q; q - private static final Map<String, RenderType> CACHE_A = new HashMap<>();1 u8 o; F6 A4 D. w3 i1 ^
- private static final Map<ResourceLocation, RenderType> CACHE_B = new HashMap<>();" r% E' D9 ~+ m
- ( _8 u* C4 Y8 I! J1 ^4 m- z
- 7 o$ w% ~1 S/ k6 W
- public void renderLine(float x1, float y1, float z1, float x2, float y2, float z2){
9 e+ |5 f2 V3 F - if(x1 == x2 && y1 == y2 && z1 == z2){
* r( S) |. ^7 m# H* \6 _ - return;
$ z. F0 p) ?: u B `, I6 D- R - }
8 F4 n; g9 e/ c5 s) z6 P7 T - if((x1 == 114514 && z1 == 114514) || (x1 == -114514 && z1 == -114514)){2 I7 ~3 O/ w) C6 M2 a) Q2 x6 F
- System.out.printIn("Looks like you put it in a henhenaaaaaaa pos. Oh, Homo is everywhere! :)");
+ t5 [- Z3 [/ {- B5 } - }/ f" H) ~' b3 V2 i* W
- pose.pushPose();/ s* E* o" U& `* o8 ?" \
- final int newLight = convertLight(6);( k$ N6 l) Q* W. V- o
- final VertexConsumer vertexs = source.getBuffer(getRenderLayer("mtrfac:textures/custom_render/lines.png", newLight, false));
* S- v2 f, x8 B0 l1 S - final float lineHeightSmall = (y2 - y1);1 [- E7 ~7 _2 ~4 J( t
- this.draw(pose, source, x1, y1 + lineHeightSmall * i, z1, x2, y1 + lineHeightSmall * (i + 1), z2, facing, 0xFF000000, newLight);7 C$ y& d7 P% T# B! L$ D
- pose.popPose();
) X4 S' p+ E2 U - }
! g, w L1 a6 Y8 _- D - % `, C% l( d. D, X5 O. b& r
- private RenderType getLayers(String texture, int light) {
6 ?. R4 b- I4 B0 U3 U - return light == MAX_LIGHT_GLOWING ? this.getLightTexture(new ResourceLocation(texture)) : this.getTexture(new ResourceLocation(texture));
: d! u- M) y; O3 Y' m1 x - }
* y3 b8 r$ _ @+ Z1 _ - 5 o+ X; i" Q7 } u9 T
- private RenderType getLightTexture(ResourceLocation texture) {
0 V# v; T( V# T" v) n2 A! X - return this.cache(texture.toString() + false, () -> beaconBeam(texture, false), CACHE_A);" l: M1 a2 v# r4 ~) L
- }; b# J4 W+ l* Y( a
) i& T6 F& T& D- [' o; r$ h" P6 O- private RenderType getTexture(ResourceLocation texture) {( D F3 F1 d$ ^' k
- return this.cache(texture, () -> entityCutout(texture), CACHE_B);" c3 b" k+ r& Y" J4 U8 R. f9 A, a
- }
! S' t0 y+ I" k6 n - 4 l; m) u1 ?( O) A! i
- private static <T> RenderType cache(T identifier, Supplier<RenderType> supplier, Map<T, RenderType> cache) {6 _' q$ g5 V, a+ F8 b
- if (cache.containsKey(identifier)) {
% A2 D& E) g& Q2 k: U' I. ~ - return cache.get(identifier);6 |; d2 Z, ?0 l; _# J# e- n
- } else {
" a8 n8 E+ ~, k, F3 `9 B: Y - final RenderType renderLayer = supplier.get();
9 o" s2 T0 G5 F0 R! d0 M8 u! S - cache.put(identifier, renderLayer);& S P8 Y: X0 }6 d3 ^3 e% U% h. R
- return renderLayer;; C* s$ N$ r+ n6 {; O' t
- }
% U0 j# P; u7 G0 b! h/ ]1 a - }7 g" Q/ V* b9 Z: B0 {9 n. \
- }
复制代码 |
|