Skip to content

Commit 74299e6

Browse files
committed
Migrate tunnel blockstate/model files to generators
1 parent 4d1c60c commit 74299e6

File tree

16 files changed

+90
-80
lines changed

16 files changed

+90
-80
lines changed

src/generated/resources/.cache/cache

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
df4f774cf0ac0996ff2ddd7d9e74b4c430160efa assets/compactmachines/blockstates/tunnel_wall.json
2-
dd5fedb75b88f5a73dc9e6fc80cab82d91503006 assets/compactmachines/models/tunnels/down.json
3-
2cb164c9b1433c7aa7315a4bb6fb67ac9ade6b01 assets/compactmachines/models/tunnels/east.json
4-
80a3a91bcda38e4ef35dc3878cca84d324224c88 assets/compactmachines/models/tunnels/north.json
5-
cd70a0a064553ec97a5f13fabde35cbf04866577 assets/compactmachines/models/tunnels/south.json
6-
faf09da76382086c8c46cbdf4410bd62dd693eee assets/compactmachines/models/tunnels/up.json
7-
8ebcc025cd056127557ca5143b217bc4e6e9a012 assets/compactmachines/models/tunnels/west.json
2+
7ce0bf865e6842abe3033e8ce6bb72ff85e0bbd0 assets/compactmachines/models/tunnels/base.json
3+
ccd9841486b1a03f50c906c2b0f7813938368099 assets/compactmachines/models/tunnels/down.json
4+
196ca7fe376c1b974b1ce3789dd464c2f4a784b8 assets/compactmachines/models/tunnels/east.json
5+
bb446af024870e7a07d31a3c78cab75797392cd5 assets/compactmachines/models/tunnels/north.json
6+
2781d8f8d22db668495872f1bb39e2dd1290ab66 assets/compactmachines/models/tunnels/south.json
7+
955410e7497ca2252d75eac53d02fb96992d94c7 assets/compactmachines/models/tunnels/up.json
8+
f8748baf2b48a44db2cf8d3872bd09b54a822560 assets/compactmachines/models/tunnels/west.json
89
95bb11d93b0dee59240d959bc881caea0115970f data/compactmachines/advancements/recipes/compactmachines/personal_shrinking_device.json
910
b86297267feb2e7d28cb68a830a0d7ffd6b6539a data/compactmachines/advancements/recipes/compactmachines/wall.json
1011
fb5c7560898ae604661d0655c2a39e923eb1d4b4 data/compactmachines/loot_tables/blocks/machine_giant.json

src/main/resources/assets/compactmachines/models/tunnels/base.json renamed to src/generated/resources/assets/compactmachines/models/tunnels/base.json

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,119 +6,125 @@
66
},
77
"elements": [
88
{
9-
"from": [0, 0, 0],
10-
"to": [16, 16, 16],
9+
"from": [
10+
0,
11+
0,
12+
0
13+
],
14+
"to": [
15+
16,
16+
16,
17+
16
18+
],
1119
"faces": {
1220
"down": {
13-
"uv": [0, 0, 16, 16],
1421
"texture": "#wall",
1522
"cullface": "down"
1623
},
1724
"up": {
18-
"uv": [0, 0, 16, 16],
1925
"texture": "#wall",
2026
"cullface": "up"
2127
},
2228
"north": {
23-
"uv": [0, 0, 16, 16],
2429
"texture": "#wall",
2530
"cullface": "north"
2631
},
2732
"south": {
28-
"uv": [0, 0, 16, 16],
2933
"texture": "#wall",
3034
"cullface": "south"
3135
},
3236
"west": {
33-
"uv": [0, 0, 16, 16],
3437
"texture": "#wall",
3538
"cullface": "west"
3639
},
3740
"east": {
38-
"uv": [0, 0, 16, 16],
3941
"texture": "#wall",
4042
"cullface": "east"
4143
}
4244
}
4345
},
4446
{
45-
"from": [0, 0, 0],
46-
"to": [16, 16, 16],
47+
"from": [
48+
0,
49+
0,
50+
0
51+
],
52+
"to": [
53+
16,
54+
16,
55+
16
56+
],
4757
"faces": {
4858
"down": {
49-
"uv": [0, 0, 16, 16],
5059
"texture": "#tunnel",
5160
"cullface": "down",
5261
"tintindex": 0
5362
},
5463
"up": {
55-
"uv": [0, 0, 16, 16],
5664
"texture": "#tunnel",
5765
"cullface": "up",
5866
"tintindex": 0
5967
},
6068
"north": {
61-
"uv": [0, 0, 16, 16],
6269
"texture": "#tunnel",
6370
"cullface": "north",
6471
"tintindex": 0
6572
},
6673
"south": {
67-
"uv": [0, 0, 16, 16],
6874
"texture": "#tunnel",
6975
"cullface": "south",
7076
"tintindex": 0
7177
},
7278
"west": {
73-
"uv": [0, 0, 16, 16],
7479
"texture": "#tunnel",
7580
"cullface": "west",
7681
"tintindex": 0
7782
},
7883
"east": {
79-
"uv": [0, 0, 16, 16],
8084
"texture": "#tunnel",
8185
"cullface": "east",
8286
"tintindex": 0
8387
}
8488
}
8589
},
8690
{
87-
"from": [0, 0, 0],
88-
"to": [16, 16, 16],
91+
"from": [
92+
0,
93+
0,
94+
0
95+
],
96+
"to": [
97+
16,
98+
16,
99+
16
100+
],
89101
"faces": {
90102
"down": {
91-
"uv": [0, 0, 16, 16],
92103
"texture": "#indicator",
93104
"cullface": "down",
94105
"tintindex": 1
95106
},
96107
"up": {
97-
"uv": [0, 0, 16, 16],
98108
"texture": "#indicator",
99109
"cullface": "up",
100110
"tintindex": 1
101111
},
102112
"north": {
103-
"uv": [0, 0, 16, 16],
104113
"texture": "#indicator",
105114
"cullface": "north",
106115
"tintindex": 1
107116
},
108117
"south": {
109-
"uv": [0, 0, 16, 16],
110118
"texture": "#indicator",
111119
"cullface": "south",
112120
"tintindex": 1
113121
},
114122
"west": {
115-
"uv": [0, 0, 16, 16],
116123
"texture": "#indicator",
117124
"cullface": "west",
118125
"tintindex": 1
119126
},
120127
"east": {
121-
"uv": [0, 0, 16, 16],
122128
"texture": "#indicator",
123129
"cullface": "east",
124130
"tintindex": 1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"parent": "minecraft:block/cube_all",
2+
"parent": "compactmachines:tunnels/base",
33
"textures": {
4-
"all": "compactmachines:block/tunnels/down"
4+
"wall": "compactmachines:block/tunnels/down"
55
}
66
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"parent": "minecraft:block/cube_all",
2+
"parent": "compactmachines:tunnels/base",
33
"textures": {
4-
"all": "compactmachines:block/tunnels/east"
4+
"wall": "compactmachines:block/tunnels/east"
55
}
66
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"parent": "minecraft:block/cube_all",
2+
"parent": "compactmachines:tunnels/base",
33
"textures": {
4-
"all": "compactmachines:block/tunnels/north"
4+
"wall": "compactmachines:block/tunnels/north"
55
}
66
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"parent": "minecraft:block/cube_all",
2+
"parent": "compactmachines:tunnels/base",
33
"textures": {
4-
"all": "compactmachines:block/tunnels/south"
4+
"wall": "compactmachines:block/tunnels/south"
55
}
66
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"parent": "minecraft:block/cube_all",
2+
"parent": "compactmachines:tunnels/base",
33
"textures": {
4-
"all": "compactmachines:block/tunnels/up"
4+
"wall": "compactmachines:block/tunnels/up"
55
}
66
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"parent": "minecraft:block/cube_all",
2+
"parent": "compactmachines:tunnels/base",
33
"textures": {
4-
"all": "compactmachines:block/tunnels/west"
4+
"wall": "compactmachines:block/tunnels/west"
55
}
66
}

src/main/java/com/robotgryphon/compactmachines/datagen/TunnelWallStateGenerator.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
import net.minecraft.block.Block;
88
import net.minecraft.data.DataGenerator;
99
import net.minecraft.util.Direction;
10+
import net.minecraft.util.ResourceLocation;
11+
import net.minecraftforge.client.model.generators.BlockModelBuilder;
1012
import net.minecraftforge.client.model.generators.BlockStateProvider;
1113
import net.minecraftforge.client.model.generators.ConfiguredModel;
14+
import net.minecraftforge.client.model.generators.ModelBuilder;
1215
import net.minecraftforge.common.data.ExistingFileHelper;
1316

1417
public class TunnelWallStateGenerator extends BlockStateProvider {
@@ -20,10 +23,15 @@ public TunnelWallStateGenerator(DataGenerator gen, ExistingFileHelper exFileHelp
2023
protected void registerStatesAndModels() {
2124
Block block = Registration.BLOCK_TUNNEL_WALL.get();
2225

26+
generateTunnelBaseModel();
27+
2328
for (Direction dir : Direction.values()) {
2429

2530
String typedTunnelDirectional = "tunnels/" + dir.getString();
26-
models().cubeAll(typedTunnelDirectional, modLoc("block/" + typedTunnelDirectional));
31+
models()
32+
.withExistingParent(typedTunnelDirectional, modLoc("tunnels/base"))
33+
.texture("wall", modLoc("block/" + typedTunnelDirectional));
34+
2735

2836
// If we ever do one-side has the texture again
2937
// int x = dir == Direction.DOWN ? 180 : dir.getAxis().isHorizontal() ? 90 : 0;
@@ -40,4 +48,34 @@ protected void registerStatesAndModels() {
4048

4149
}
4250
}
51+
52+
private void generateTunnelBaseModel() {
53+
BlockModelBuilder base = models()
54+
.withExistingParent("tunnels/base", new ResourceLocation("minecraft", "block/block"))
55+
.texture("tunnel", modLoc("block/tunnels/tunnel"))
56+
.texture("indicator", modLoc("block/tunnels/indicator"));
57+
58+
addFullCubeWithTexture(base, "#wall", -1);
59+
addFullCubeWithTexture(base, "#tunnel", 0);
60+
addFullCubeWithTexture(base, "#indicator", 1);
61+
}
62+
63+
private void addFullCubeWithTexture(BlockModelBuilder base, String texture, int tintIndex) {
64+
base.element()
65+
.from(0, 0, 0)
66+
.to(16, 16, 16)
67+
.allFaces((direction, faceBuilder) -> {
68+
ModelBuilder<BlockModelBuilder>.ElementBuilder.FaceBuilder f = faceBuilder
69+
.uvs(0, 0, 16, 16)
70+
.cullface(direction);
71+
72+
if (tintIndex > -1)
73+
f.tintindex(tintIndex);
74+
75+
f.texture(texture)
76+
77+
.end();
78+
})
79+
.end();
80+
}
4381
}

src/main/java/com/robotgryphon/compactmachines/tunnels/definitions/RedstoneTunnelDefinition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public int getTunnelRingColor() {
2828

2929
@Override
3030
public int getTunnelIndicatorColor() {
31-
return Color.ORANGE.darker().getRGB();
31+
return Color.blue.getRGB();
32+
// return Color.ORANGE.darker().getRGB();
3233
}
3334

3435
@Override

0 commit comments

Comments
 (0)