Skip to content

Commit 3780573

Browse files
committed
Basic recolorable field projectors
1 parent bd7e59d commit 3780573

File tree

5 files changed

+61
-99
lines changed

5 files changed

+61
-99
lines changed

src/main/java/com/robotgryphon/compactcrafting/blocks/FieldProjectorTile.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.robotgryphon.compactcrafting.blocks;
22

3+
import com.robotgryphon.compactcrafting.core.EnumProjectorColorType;
34
import com.robotgryphon.compactcrafting.core.Registration;
45
import com.robotgryphon.compactcrafting.crafting.CraftingHelper;
56
import com.robotgryphon.compactcrafting.field.FieldProjection;
@@ -21,6 +22,7 @@
2122
import net.minecraft.util.math.BlockPos;
2223
import net.minecraft.world.server.ServerWorld;
2324

25+
import java.awt.*;
2426
import java.util.Collection;
2527
import java.util.List;
2628
import java.util.Optional;
@@ -38,6 +40,26 @@ public FieldProjectorTile() {
3840
super(Registration.FIELD_PROJECTOR_TILE.get());
3941
}
4042

43+
public Color getProjectionColor(EnumProjectorColorType type) {
44+
Color base = new Color(255, 106, 0, 100);
45+
// Color base = Color.red.brighter();
46+
int red = base.getRed();
47+
int green = base.getGreen();
48+
int blue = base.getBlue();
49+
50+
switch(type) {
51+
case FIELD:
52+
case SCAN_LINE:
53+
return new Color(red, green, blue, 100);
54+
55+
case PROJECTOR_FACE:
56+
// return new Color(Color.cyan.getRed(), Color.cyan.getGreen(), Color.cyan.getBlue(), 100);
57+
return new Color(red, green, blue, 250);
58+
}
59+
60+
return Color.WHITE;
61+
}
62+
4163
@Override
4264
public void remove() {
4365
super.remove();

src/main/java/com/robotgryphon/compactcrafting/client/render/FieldProjectorRenderer.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.robotgryphon.compactcrafting.blocks.FieldProjectorBlock;
66
import com.robotgryphon.compactcrafting.blocks.FieldProjectorTile;
77
import com.robotgryphon.compactcrafting.core.Constants;
8+
import com.robotgryphon.compactcrafting.core.EnumProjectorColorType;
89
import com.robotgryphon.compactcrafting.field.FieldProjection;
910
import net.minecraft.block.BlockState;
1011
import net.minecraft.client.Minecraft;
@@ -49,10 +50,6 @@ public int getSpeed() {
4950

5051
private IBakedModel bakedModelCached;
5152

52-
private Color colorProjectionArc = new Color(255, 106, 0, 200);
53-
private final Color colorProjectionCube = new Color(255, 106, 0, 100);
54-
private final Color colorScanLine = new Color(255, 106, 0, 200);
55-
5653
public FieldProjectorRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
5754
super(rendererDispatcherIn);
5855
}
@@ -223,9 +220,17 @@ private void renderDish(FieldProjectorTile te, MatrixStack mx, IRenderTypeBuffer
223220

224221
mx.translate(-.5, 0, -.5);
225222

223+
Color faceColor = te.getProjectionColor(EnumProjectorColorType.PROJECTOR_FACE);
224+
float red = faceColor.getRed() / 255f;
225+
float green = faceColor.getGreen() / 255f;
226+
float blue = faceColor.getBlue() / 255f;
227+
226228
blockRenderer.getBlockModelRenderer()
227229
.renderModel(mx.getLast(), cutoutBlocks, state,
228-
baked, 1, 1, 1,
230+
baked,
231+
red,
232+
green,
233+
blue,
229234
combinedLight, combinedOverlay, model);
230235

231236
mx.pop();
@@ -270,7 +275,7 @@ private void renderProjectionCube(FieldProjectorTile tile, MatrixStack mx, IRend
270275
.expand(expansion, expansion, expansion)
271276
.expand(-expansion, -expansion, -expansion);
272277

273-
drawCube(builder, mx, slightlyBiggerBecauseFoxes, colorProjectionCube);
278+
drawCube(builder, mx, slightlyBiggerBecauseFoxes, tile.getProjectionColor(EnumProjectorColorType.FIELD));
274279

275280
mx.pop();
276281
}
@@ -298,6 +303,8 @@ private void drawProjectorArcs(FieldProjectorTile tile, MatrixStack mx, IRenderT
298303

299304
mx.rotate(rotation);
300305

306+
Color colorProjectionArc = tile.getProjectionColor(EnumProjectorColorType.SCAN_LINE);
307+
301308
// 0, 0, 0 is now the edge of the projector's space
302309
addColoredVertex(builder, mx, colorProjectionArc, new Vector3f(0f, 0f, 0f));
303310

@@ -390,6 +397,7 @@ private void drawScanLines(FieldProjectorTile tile, MatrixStack mx, IRenderTypeB
390397

391398
AxisAlignedBB scanLineMain = new AxisAlignedBB(cube.minX, scanHeight, cube.minZ, cube.maxX, scanHeight, cube.maxZ);
392399

400+
Color colorScanLine = tile.getProjectionColor(EnumProjectorColorType.SCAN_LINE);
393401
drawRing(builder, mx, scanLineMain, colorScanLine);
394402

395403
mx.pop();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.robotgryphon.compactcrafting.core;
2+
3+
public enum EnumProjectorColorType {
4+
FIELD,
5+
SCAN_LINE,
6+
PROJECTOR_FACE
7+
}

src/main/resources/assets/compactcrafting/models/block/field_projector_dish.json

Lines changed: 18 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -6,142 +6,67 @@
66
"elements": [
77
{
88
"name": "Dish",
9-
"from": [
10-
4,
11-
8,
12-
3
13-
],
14-
"to": [
15-
6,
16-
16,
17-
13
18-
],
9+
"from": [4, 8, 3],
10+
"to": [6, 16, 13],
1911
"shade": true,
2012
"faces": {
2113
"north": {
22-
"uv": [
23-
12.5,
24-
8,
25-
13.5,
26-
11.5
27-
],
14+
"uv": [12.5, 8, 13.5, 11.5],
2815
"texture": "#0"
2916
},
3017
"east": {
31-
"uv": [
32-
8,
33-
12,
34-
13,
35-
16
36-
],
18+
"uv": [8, 12, 13, 16],
3719
"texture": "#0"
3820
},
3921
"south": {
40-
"uv": [
41-
12.5,
42-
8,
43-
13.5,
44-
11.5
45-
],
22+
"uv": [12.5, 8, 13.5, 11.5],
4623
"texture": "#0"
4724
},
4825
"west": {
49-
"uv": [
50-
8,
51-
8,
52-
13,
53-
12
54-
],
55-
"texture": "#0"
26+
"uv": [8, 8, 13, 12],
27+
"texture": "#0",
28+
"tintindex": 0
5629
},
5730
"up": {
58-
"uv": [
59-
8,
60-
11.5,
61-
13,
62-
12.5
63-
],
31+
"uv": [8, 11.5, 13, 12.5],
6432
"texture": "#0",
6533
"rotation": 90
6634
},
6735
"down": {
68-
"uv": [
69-
8,
70-
11.5,
71-
13,
72-
12.5
73-
],
36+
"uv": [8, 11.5, 13, 12.5],
7437
"texture": "#0",
7538
"rotation": 90
7639
}
7740
}
7841
},
7942
{
8043
"name": "Connector",
81-
"from": [
82-
6,
83-
11,
84-
7
85-
],
86-
"to": [
87-
7,
88-
13,
89-
9
90-
],
44+
"from": [6, 11, 7],
45+
"to": [7, 13, 9],
9146
"shade": true,
9247
"faces": {
9348
"north": {
94-
"uv": [
95-
4.5,
96-
10,
97-
5,
98-
11
99-
],
49+
"uv": [4.5, 10, 5, 11],
10050
"texture": "#0"
10151
},
10252
"east": {
103-
"uv": [
104-
4,
105-
10,
106-
5,
107-
11
108-
],
53+
"uv": [4, 10, 5, 11],
10954
"texture": "#0"
11055
},
11156
"south": {
112-
"uv": [
113-
4.5,
114-
10,
115-
5,
116-
11
117-
],
57+
"uv": [4.5, 10, 5, 11],
11858
"texture": "#0"
11959
},
12060
"west": {
121-
"uv": [
122-
0,
123-
0,
124-
2,
125-
2
126-
],
61+
"uv": [0, 0, 2, 2],
12762
"texture": "#0"
12863
},
12964
"up": {
130-
"uv": [
131-
4.5,
132-
10,
133-
5,
134-
11
135-
],
65+
"uv": [4.5, 10, 5, 11],
13666
"texture": "#0"
13767
},
13868
"down": {
139-
"uv": [
140-
4.5,
141-
10,
142-
5,
143-
11
144-
],
69+
"uv": [4.5, 10, 5, 11],
14570
"texture": "#0"
14671
}
14772
}
-14.8 KB
Loading

0 commit comments

Comments
 (0)