|
12 | 12 | import net.minecraft.client.model.ModelPart; |
13 | 13 | import net.minecraft.client.render.RenderLayer; |
14 | 14 | import net.minecraft.client.render.block.MovingBlockRenderState; |
| 15 | +import net.minecraft.client.render.command.BatchingRenderCommandQueue; |
15 | 16 | import net.minecraft.client.render.command.ModelCommandRenderer; |
16 | 17 | import net.minecraft.client.render.command.OrderedRenderCommandQueueImpl; |
17 | 18 | import net.minecraft.client.render.entity.state.EntityHitboxAndView; |
|
33 | 34 |
|
34 | 35 | public class OutlineRenderCommandQueue extends OrderedRenderCommandQueueImpl { |
35 | 36 | private int color; |
| 37 | + private int[] tints; |
36 | 38 |
|
37 | 39 | public void setColor(Color color) { |
38 | 40 | this.color = color.getPacked(); |
39 | 41 | } |
40 | 42 |
|
41 | | - // OrderedRenderCommandQueueImpl |
42 | | - |
43 | | - @Override |
44 | | - public void submitDebugHitbox(MatrixStack matrices, EntityRenderState renderState, EntityHitboxAndView debugHitbox) { |
45 | | - } |
46 | | - |
47 | | - @Override |
48 | | - public void submitShadowPieces(MatrixStack matrices, float shadowRadius, List<EntityRenderState.ShadowPiece> shadowPieces) { |
49 | | - } |
50 | | - |
51 | | - @Override |
52 | | - public void submitLabel(MatrixStack matrices, @Nullable Vec3d nameLabelPos, int y, Text label, boolean notSneaking, int light, double squaredDistanceToCamera, CameraRenderState cameraState) { |
53 | | - } |
54 | | - |
55 | 43 | @Override |
56 | | - public void submitText(MatrixStack matrices, float x, float y, OrderedText text, boolean dropShadow, TextRenderer.TextLayerType layerType, int light, int color, int backgroundColor, int outlineColor) { |
| 44 | + public BatchingRenderCommandQueue getBatchingQueue(int i) { |
| 45 | + return batchingQueues.computeIfAbsent(i, order -> new OutlineBatchingRenderCommandQueue(this)); |
57 | 46 | } |
58 | 47 |
|
59 | | - @Override |
60 | | - public void submitFire(MatrixStack matrices, EntityRenderState renderState, Quaternionf rotation) { |
61 | | - } |
62 | | - |
63 | | - @Override |
64 | | - public void submitLeash(MatrixStack matrices, EntityRenderState.LeashData leashData) { |
65 | | - } |
66 | | - |
67 | | - @Override |
68 | | - public <S> void submitModel(Model<? super S> model, S state, MatrixStack matrices, RenderLayer renderLayer, int light, int overlay, int tintedColor, @Nullable Sprite sprite, int outlineColor, @Nullable ModelCommandRenderer.CrumblingOverlayCommand crumblingOverlay) { |
69 | | - super.submitModel(model, state, matrices, renderLayer, light, overlay, color, sprite, 0, crumblingOverlay); |
70 | | - } |
71 | | - |
72 | | - @Override |
73 | | - public void submitModelPart(ModelPart part, MatrixStack matrices, RenderLayer renderLayer, int light, int overlay, @Nullable Sprite sprite, boolean sheeted, boolean hasGlint, int tintedColor, ModelCommandRenderer.CrumblingOverlayCommand crumblingOverlay, int i) { |
74 | | - super.submitModelPart(part, matrices, renderLayer, light, overlay, sprite, sheeted, hasGlint, color, crumblingOverlay, i); |
75 | | - } |
76 | | - |
77 | | - @Override |
78 | | - public void submitBlock(MatrixStack matrices, BlockState state, int light, int overlay, int outlineColor) { |
79 | | - } |
80 | | - |
81 | | - @Override |
82 | | - public void submitMovingBlock(MatrixStack matrices, MovingBlockRenderState state) { |
83 | | - } |
84 | | - |
85 | | - @Override |
86 | | - public void submitBlockStateModel(MatrixStack matrices, RenderLayer renderLayer, BlockStateModel model, float r, float g, float b, int light, int overlay, int outlineColor) { |
87 | | - r = Color.toRGBAR(color) / 255f; |
88 | | - g = Color.toRGBAG(color) / 255f; |
89 | | - b = Color.toRGBAB(color) / 255f; |
90 | | - |
91 | | - super.submitBlockStateModel(matrices, renderLayer, model, r, g, b, light, overlay, 0); |
92 | | - } |
93 | | - |
94 | | - @Override |
95 | | - public void submitItem(MatrixStack matrices, ItemDisplayContext displayContext, int light, int overlay, int outlineColors, int[] tintLayers, List<BakedQuad> quads, RenderLayer renderLayer, ItemRenderState.Glint glintType) { |
96 | | - } |
97 | | - |
98 | | - @Override |
99 | | - public void submitCustom(MatrixStack matrices, RenderLayer renderLayer, Custom customRenderer) { |
100 | | - } |
101 | | - |
102 | | - @Override |
103 | | - public void submitCustom(LayeredCustom customRenderer) { |
| 48 | + private class OutlineBatchingRenderCommandQueue extends BatchingRenderCommandQueue { |
| 49 | + public OutlineBatchingRenderCommandQueue(OrderedRenderCommandQueueImpl orderedQueueImpl) { |
| 50 | + super(orderedQueueImpl); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public void submitDebugHitbox(MatrixStack matrices, EntityRenderState renderState, EntityHitboxAndView debugHitbox) { |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public void submitShadowPieces(MatrixStack matrices, float shadowRadius, List<EntityRenderState.ShadowPiece> shadowPieces) { |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public void submitLabel(MatrixStack matrices, @Nullable Vec3d nameLabelPos, int y, Text label, boolean notSneaking, int light, double squaredDistanceToCamera, CameraRenderState cameraState) { |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public void submitText(MatrixStack matrices, float x, float y, OrderedText text, boolean dropShadow, TextRenderer.TextLayerType layerType, int light, int color, int backgroundColor, int outlineColor) { |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + public void submitFire(MatrixStack matrices, EntityRenderState renderState, Quaternionf rotation) { |
| 71 | + } |
| 72 | + |
| 73 | + @Override |
| 74 | + public void submitLeash(MatrixStack matrices, EntityRenderState.LeashData leashData) { |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public <S> void submitModel(Model<? super S> model, S state, MatrixStack matrices, RenderLayer renderLayer, int light, int overlay, int tintedColor, @Nullable Sprite sprite, int outlineColor, @Nullable ModelCommandRenderer.CrumblingOverlayCommand crumblingOverlay) { |
| 79 | + super.submitModel(model, state, matrices, renderLayer, light, overlay, color, sprite, 0, crumblingOverlay); |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public void submitModelPart(ModelPart part, MatrixStack matrices, RenderLayer renderLayer, int light, int overlay, @Nullable Sprite sprite, boolean sheeted, boolean hasGlint, int tintedColor, @Nullable ModelCommandRenderer.CrumblingOverlayCommand crumblingOverlay, int i) { |
| 84 | + super.submitModelPart(part, matrices, renderLayer, light, overlay, sprite, sheeted, hasGlint, color, crumblingOverlay, i); |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public void submitBlock(MatrixStack matrices, BlockState state, int light, int overlay, int outlineColor) { |
| 89 | + } |
| 90 | + |
| 91 | + @Override |
| 92 | + public void submitMovingBlock(MatrixStack matrices, MovingBlockRenderState state) { |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public void submitBlockStateModel(MatrixStack matrices, RenderLayer renderLayer, BlockStateModel model, float r, float g, float b, int light, int overlay, int outlineColor) { |
| 97 | + r = Color.toRGBAR(color) / 255f; |
| 98 | + g = Color.toRGBAG(color) / 255f; |
| 99 | + b = Color.toRGBAB(color) / 255f; |
| 100 | + |
| 101 | + super.submitBlockStateModel(matrices, renderLayer, model, r, g, b, light, overlay, outlineColor); |
| 102 | + } |
| 103 | + |
| 104 | + @Override |
| 105 | + public void submitItem(MatrixStack matrices, ItemDisplayContext displayContext, int light, int overlay, int outlineColors, int[] tintLayers, List<BakedQuad> quads, RenderLayer renderLayer, ItemRenderState.Glint glintType) { |
| 106 | + if (tints == null || tints[0] != color) { |
| 107 | + tints = new int[] { color, color, color, color }; |
| 108 | + } |
| 109 | + |
| 110 | + super.submitItem(matrices, displayContext, light, overlay, outlineColors, tints, quads, renderLayer, glintType); |
| 111 | + } |
| 112 | + |
| 113 | + @Override |
| 114 | + public void submitCustom(MatrixStack matrices, RenderLayer renderLayer, Custom customRenderer) { |
| 115 | + } |
| 116 | + |
| 117 | + @Override |
| 118 | + public void submitCustom(LayeredCustom customRenderer) { |
| 119 | + } |
104 | 120 | } |
105 | 121 | } |
0 commit comments