| 1 | package com.mojang.blaze3d.vertex;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.renderer.texture.OverlayTexture;
|
| 6 | import net.minecraft.util.ARGB;
|
| 7 | import net.minecraft.util.LightCoordsUtil;
|
| 8 |
|
| 9 | @Environment(EnvType.CLIENT)
|
| 10 | public class QuadInstance {
|
| 11 | private int color0 = -1;
|
| 12 | private int color1 = -1;
|
| 13 | private int color2 = -1;
|
| 14 | private int color3 = -1;
|
| 15 | private int lightCoords0 = 15728880;
|
| 16 | private int lightCoords1 = 15728880;
|
| 17 | private int lightCoords2 = 15728880;
|
| 18 | private int lightCoords3 = 15728880;
|
| 19 | private int overlayCoords = OverlayTexture.NO_OVERLAY;
|
| 20 |
|
| 21 | public int getColor(final int vertex) {
|
| 22 | return switch (vertex) {
|
| 23 | case 0 -> this.color0;
|
| 24 | case 1 -> this.color1;
|
| 25 | case 2 -> this.color2;
|
| 26 | case 3 -> this.color3;
|
| 27 | default -> throw new IndexOutOfBoundsException();
|
| 28 | };
|
| 29 | }
|
| 30 |
|
| 31 | public int getLightCoords(final int vertex) {
|
| 32 | return switch (vertex) {
|
| 33 | case 0 -> this.lightCoords0;
|
| 34 | case 1 -> this.lightCoords1;
|
| 35 | case 2 -> this.lightCoords2;
|
| 36 | case 3 -> this.lightCoords3;
|
| 37 | default -> throw new IndexOutOfBoundsException();
|
| 38 | };
|
| 39 | }
|
| 40 |
|
| 41 | public int getLightCoordsWithEmission(final int vertex, final int lightEmission) {
|
| 42 | return LightCoordsUtil.lightCoordsWithEmission(this.getLightCoords(vertex), lightEmission);
|
| 43 | }
|
| 44 |
|
| 45 | public int overlayCoords() {
|
| 46 | return this.overlayCoords;
|
| 47 | }
|
| 48 |
|
| 49 | public void setColor(final int vertex, final int color) {
|
| 50 | switch (vertex) {
|
| 51 | case 0:
|
| 52 | this.color0 = color;
|
| 53 | break;
|
| 54 | case 1:
|
| 55 | this.color1 = color;
|
| 56 | break;
|
| 57 | case 2:
|
| 58 | this.color2 = color;
|
| 59 | break;
|
| 60 | case 3:
|
| 61 | this.color3 = color;
|
| 62 | break;
|
| 63 | default:
|
| 64 | throw new IndexOutOfBoundsException();
|
| 65 | }
|
| 66 | }
|
| 67 |
|
| 68 | public void setLightCoords(final int vertex, final int lightCoords) {
|
| 69 | switch (vertex) {
|
| 70 | case 0:
|
| 71 | this.lightCoords0 = lightCoords;
|
| 72 | break;
|
| 73 | case 1:
|
| 74 | this.lightCoords1 = lightCoords;
|
| 75 | break;
|
| 76 | case 2:
|
| 77 | this.lightCoords2 = lightCoords;
|
| 78 | break;
|
| 79 | case 3:
|
| 80 | this.lightCoords3 = lightCoords;
|
| 81 | break;
|
| 82 | default:
|
| 83 | throw new IndexOutOfBoundsException();
|
| 84 | }
|
| 85 | }
|
| 86 |
|
| 87 | public void setColor(final int color) {
|
| 88 | this.color0 = color;
|
| 89 | this.color1 = color;
|
| 90 | this.color2 = color;
|
| 91 | this.color3 = color;
|
| 92 | }
|
| 93 |
|
| 94 | public void setLightCoords(final int lightCoords) {
|
| 95 | this.lightCoords0 = lightCoords;
|
| 96 | this.lightCoords1 = lightCoords;
|
| 97 | this.lightCoords2 = lightCoords;
|
| 98 | this.lightCoords3 = lightCoords;
|
| 99 | }
|
| 100 |
|
| 101 | public void setOverlayCoords(final int overlayCoords) {
|
| 102 | this.overlayCoords = overlayCoords;
|
| 103 | }
|
| 104 |
|
| 105 | public void multiplyColor(final int color) {
|
| 106 | this.color0 = ARGB.multiply(this.color0, color);
|
| 107 | this.color1 = ARGB.multiply(this.color1, color);
|
| 108 | this.color2 = ARGB.multiply(this.color2, color);
|
| 109 | this.color3 = ARGB.multiply(this.color3, color);
|
| 110 | }
|
| 111 |
|
| 112 | public void scaleColor(final float scale) {
|
| 113 | this.color0 = ARGB.scaleRGB(this.color0, scale);
|
| 114 | this.color1 = ARGB.scaleRGB(this.color1, scale);
|
| 115 | this.color2 = ARGB.scaleRGB(this.color2, scale);
|
| 116 | this.color3 = ARGB.scaleRGB(this.color3, scale);
|
| 117 | }
|
| 118 | }
|
| 119 |
|