Skip to content

Commit 38aee8a

Browse files
committed
Apply new datagen on parallel gearbox to fix uv rotation (#55)
1 parent 62961bf commit 38aee8a

File tree

6 files changed

+128
-27
lines changed

6 files changed

+128
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
{
22
"variants": {
33
"axis=x": {
4-
"model": "create_connected:block/parallel_gearbox/block",
5-
"x": 90,
6-
"y": 90
4+
"model": "create_connected:block/parallel_gearbox/block_x"
75
},
86
"axis=y": {
9-
"model": "create_connected:block/parallel_gearbox/block"
7+
"model": "create_connected:block/parallel_gearbox/block_y"
108
},
119
"axis=z": {
12-
"model": "create_connected:block/parallel_gearbox/block",
13-
"x": 90,
14-
"y": 180
10+
"model": "create_connected:block/parallel_gearbox/block_z"
1511
}
1612
}
1713
}

src/main/java/com/hlysine/create_connected/CCBlocks.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public class CCBlocks {
119119
.onRegister(CreateRegistrate.connectedTextures(() -> new EncasedCTBehaviour(AllSpriteShifts.ANDESITE_CASING)))
120120
.onRegister(CreateRegistrate.casingConnectivity((block, cc) -> cc.make(block, AllSpriteShifts.ANDESITE_CASING,
121121
(s, f) -> f.getAxis() == s.getValue(ParallelGearboxBlock.AXIS))))
122-
.blockstate((c, p) -> CCBlockStateGen.axisBlock(c, p, $ -> partialBaseModel(c, p), false))
122+
.blockstate(CCBlockStateGen.axisBlock())
123123
.item()
124124
.transform(customItemModel())
125125
.register();
@@ -132,7 +132,7 @@ public class CCBlocks {
132132
.transform(FeatureToggle.register())
133133
.transform(axeOrPickaxe())
134134
.lang("6-way Gearbox")
135-
.blockstate((c, p) -> CCBlockStateGen.axisBlock(c, p, $ -> partialBaseModel(c, p), false))
135+
.blockstate((c, p) -> axisBlock(c, p, $ -> partialBaseModel(c, p), false))
136136
.item()
137137
.transform(customItemModel())
138138
.register();

src/main/java/com/hlysine/create_connected/datagen/CCBlockStateGen.java

+27-18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.hlysine.create_connected.content.sequencedpulsegenerator.SequencedPulseGeneratorBlock;
66
import com.mojang.datafixers.util.Function4;
77
import com.mojang.datafixers.util.Function5;
8+
import com.simibubi.create.content.kinetics.base.RotatedPillarKineticBlock;
9+
import com.simibubi.create.content.kinetics.gearbox.GearboxBlock;
810
import com.simibubi.create.foundation.utility.Iterate;
911
import com.tterrag.registrate.providers.DataGenContext;
1012
import com.tterrag.registrate.providers.RegistrateBlockstateProvider;
@@ -173,26 +175,33 @@ public static <B extends BrassGearboxBlock> NonNullBiConsumer<DataGenContext<Blo
173175
};
174176

175177
p.getVariantBuilder(c.getEntry())
176-
.forAllStatesExcept(state -> {
177-
return ConfiguredModel.builder()
178-
.modelFile(modelFunc.apply(state))
179-
.uvLock(false)
180-
.build();
181-
}, BlockStateProperties.WATERLOGGED);
178+
.forAllStatesExcept(
179+
state -> ConfiguredModel.builder()
180+
.modelFile(modelFunc.apply(state))
181+
.uvLock(false)
182+
.build(),
183+
BlockStateProperties.WATERLOGGED
184+
);
182185
};
183186
}
184187

185-
public static <T extends Block> void axisBlock(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov,
186-
Function<BlockState, ModelFile> modelFunc, boolean uvLock) {
187-
prov.getVariantBuilder(ctx.getEntry())
188-
.forAllStatesExcept(state -> {
189-
Direction.Axis axis = state.getValue(BlockStateProperties.AXIS);
190-
return ConfiguredModel.builder()
191-
.modelFile(modelFunc.apply(state))
192-
.uvLock(uvLock)
193-
.rotationX(axis == Direction.Axis.Y ? 0 : 90)
194-
.rotationY(axis == Direction.Axis.X ? 90 : axis == Direction.Axis.Z ? 180 : 0)
195-
.build();
196-
}, BlockStateProperties.WATERLOGGED);
188+
public static <B extends RotatedPillarKineticBlock> NonNullBiConsumer<DataGenContext<Block, B>, RegistrateBlockstateProvider> axisBlock() {
189+
return (c, p) -> {
190+
Vector<ModelFile> models = new Vector<>(16);
191+
for (Direction.Axis axis : Iterate.axes)
192+
models.add(p.models().getExistingFile(p.modLoc("block/" + c.getName() + "/block_" + axis.getName())));
193+
Function<BlockState, ModelFile> modelFunc = (state) -> {
194+
Direction.Axis axis = state.getValue(BrassGearboxBlock.AXIS);
195+
return models.get(axis.ordinal());
196+
};
197+
p.getVariantBuilder(c.getEntry())
198+
.forAllStatesExcept(
199+
state -> ConfiguredModel.builder()
200+
.modelFile(modelFunc.apply(state))
201+
.uvLock(false)
202+
.build(),
203+
BlockStateProperties.WATERLOGGED
204+
);
205+
};
197206
}
198207
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"credit": "Made with Blockbench",
3+
"parent": "block/block",
4+
"textures": {
5+
"0": "create:block/andesite_casing",
6+
"1": "create_connected:block/gearbox",
7+
"particle": "create:block/andesite_casing"
8+
},
9+
"elements": [
10+
{
11+
"name": "Bottom",
12+
"from": [0, 0, 0],
13+
"to": [2, 16, 16],
14+
"faces": {
15+
"north": {"uv": [0, 14, 16, 16], "rotation": 270, "texture": "#0"},
16+
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
17+
"south": {"uv": [0, 14, 16, 16], "rotation": 90, "texture": "#0"},
18+
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
19+
"up": {"uv": [0, 14, 16, 16], "rotation": 90, "texture": "#0"},
20+
"down": {"uv": [0, 14, 16, 16], "rotation": 90, "texture": "#0"}
21+
}
22+
},
23+
{
24+
"name": "Core",
25+
"from": [2, 0.95, 0.95],
26+
"to": [14, 15.05, 15.05],
27+
"faces": {
28+
"north": {"uv": [1, 2, 15, 14], "rotation": 270, "texture": "#1"},
29+
"south": {"uv": [1, 2, 15, 14], "rotation": 90, "texture": "#1"},
30+
"up": {"uv": [1, 2, 15, 14], "rotation": 90, "texture": "#1"},
31+
"down": {"uv": [1, 2, 15, 14], "rotation": 90, "texture": "#1"}
32+
}
33+
},
34+
{
35+
"name": "Top",
36+
"from": [14, 0, 0],
37+
"to": [16, 16, 16],
38+
"faces": {
39+
"north": {"uv": [0, 0, 16, 2], "rotation": 270, "texture": "#0"},
40+
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
41+
"south": {"uv": [0, 0, 16, 2], "rotation": 90, "texture": "#0"},
42+
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
43+
"up": {"uv": [0, 0, 16, 2], "rotation": 90, "texture": "#0"},
44+
"down": {"uv": [0, 0, 16, 2], "rotation": 90, "texture": "#0"}
45+
}
46+
}
47+
]
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"credit": "Made with Blockbench",
3+
"parent": "block/block",
4+
"textures": {
5+
"0": "create:block/andesite_casing",
6+
"1": "create_connected:block/gearbox",
7+
"particle": "create:block/andesite_casing"
8+
},
9+
"elements": [
10+
{
11+
"name": "Bottom",
12+
"from": [0, 0, 0],
13+
"to": [16, 16, 2],
14+
"faces": {
15+
"north": {"uv": [0, 0, 16, 16], "texture": "#0"},
16+
"east": {"uv": [0, 14, 16, 16], "rotation": 270, "texture": "#0"},
17+
"south": {"uv": [0, 0, 16, 16], "texture": "#0"},
18+
"west": {"uv": [0, 14, 16, 16], "rotation": 90, "texture": "#0"},
19+
"up": {"uv": [0, 14, 16, 16], "rotation": 180, "texture": "#0"},
20+
"down": {"uv": [0, 14, 16, 16], "texture": "#0"}
21+
}
22+
},
23+
{
24+
"name": "Core",
25+
"from": [0.95, 0.95, 2],
26+
"to": [15.05, 15.05, 14],
27+
"faces": {
28+
"east": {"uv": [1, 2, 15, 14], "rotation": 270, "texture": "#1"},
29+
"west": {"uv": [1, 2, 15, 14], "rotation": 90, "texture": "#1"},
30+
"up": {"uv": [1, 2, 15, 14], "rotation": 180, "texture": "#1"},
31+
"down": {"uv": [1, 2, 15, 14], "texture": "#1"}
32+
}
33+
},
34+
{
35+
"name": "Top",
36+
"from": [0, 0, 14],
37+
"to": [16, 16, 16],
38+
"faces": {
39+
"north": {"uv": [0, 0, 16, 16], "texture": "#0"},
40+
"east": {"uv": [0, 0, 16, 2], "rotation": 270, "texture": "#0"},
41+
"south": {"uv": [0, 0, 16, 16], "texture": "#0"},
42+
"west": {"uv": [0, 0, 16, 2], "rotation": 90, "texture": "#0"},
43+
"up": {"uv": [0, 0, 16, 2], "rotation": 180, "texture": "#0"},
44+
"down": {"uv": [0, 0, 16, 2], "texture": "#0"}
45+
}
46+
}
47+
]
48+
}

0 commit comments

Comments
 (0)