Skip to content

Commit e787b6d

Browse files
committed
chore: rearrange the canned food model to be easier to texture
1 parent 701b20a commit e787b6d

File tree

6 files changed

+60
-98
lines changed

6 files changed

+60
-98
lines changed

src/main/java/dev/galacticraft/mod/client/model/CannedFoodBakedModel.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@
2323
package dev.galacticraft.mod.client.model;
2424

2525
import dev.galacticraft.api.component.GCDataComponents;
26-
import dev.galacticraft.mod.content.block.decoration.CannedFoodBlock;
2726
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
28-
import net.fabricmc.fabric.api.renderer.v1.model.SpriteFinder;
2927
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
30-
import net.minecraft.client.Minecraft;
31-
import net.minecraft.client.renderer.texture.TextureAtlas;
3228
import net.minecraft.client.resources.model.BakedModel;
3329
import net.minecraft.core.BlockPos;
34-
import net.minecraft.core.Direction;
3530
import net.minecraft.util.RandomSource;
3631
import net.minecraft.world.item.ItemStack;
3732
import net.minecraft.world.level.BlockAndTintGetter;
@@ -62,9 +57,6 @@ public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, Block
6257
List<ItemStack> contents = (List<ItemStack>) blockView.getBlockEntityRenderData(pos);
6358
int canCount = contents.size();
6459

65-
TextureAtlas atlas = Minecraft.getInstance().getModelManager().getAtlas(TextureAtlas.LOCATION_BLOCKS);
66-
SpriteFinder spriteFinder = SpriteFinder.get(atlas);
67-
6860
for (int i = 0; i < canCount; i++) {
6961
float[] position = POSITIONS[canCount - 1][i];
7062
float x = (position[0] - 8) / 16.0f; // Convert pixel coords to block space
@@ -74,15 +66,13 @@ public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, Block
7466
ItemStack stack = contents.get(i);
7567
int canColor = stack.getOrDefault(GCDataComponents.COLOR, 0);
7668

77-
Direction facing = state.getValue(CannedFoodBlock.FACING);
78-
7969
context.pushTransform(quad -> {
8070
quad.pos(0, quad.x(0) + x, quad.y(0) + y, quad.z(0) + z);
8171
quad.pos(1, quad.x(1) + x, quad.y(1) + y, quad.z(1) + z);
8272
quad.pos(2, quad.x(2) + x, quad.y(2) + y, quad.z(2) + z);
8373
quad.pos(3, quad.x(3) + x, quad.y(3) + y, quad.z(3) + z);
8474

85-
if (spriteFinder.find(quad).contents().name().toString().contains("canned_food_label_texture")) {
75+
if (quad.colorIndex() != -1) {
8676
quad.color(0, canColor);
8777
quad.color(1, canColor);
8878
quad.color(2, canColor);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"parent": "block/block",
33
"textures": {
4-
"particle": "galacticraft:block/canned_food"
4+
"particle": "galacticraft:item/empty_can"
55
},
66
"elements": []
77
}

src/main/resources/assets/galacticraft/models/block/canned_food_model.json

Lines changed: 58 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,126 +2,98 @@
22
"credit": "Made with Blockbench",
33
"texture_size": [32, 32],
44
"textures": {
5-
"0": "galacticraft:block/canned_food_label_texture",
6-
"1": "galacticraft:block/canned_food_can_texture",
7-
"particle": "galacticraft:block/canned_food_can_texture"
5+
"can": "galacticraft:block/canned_food",
6+
"particle": "galacticraft:item/empty_can"
87
},
98
"elements": [
109
{
11-
"from": [5, 3, 6],
12-
"to": [6, 5, 10],
13-
"rotation": {"angle": 0, "axis": "y", "origin": [4, 3, 5]},
10+
"from": [6, 5, 5],
11+
"to": [10, 8, 11],
1412
"faces": {
15-
"north": {"uv": [4, 10, 5, 12], "texture": "#0"},
16-
"east": {"uv": [0, 8, 4, 10], "texture": "#0"},
17-
"south": {"uv": [5, 10, 6, 12], "texture": "#0"},
18-
"west": {"uv": [8, 0, 12, 2], "texture": "#0"},
19-
"up": {"uv": [1, 14, 0, 10], "texture": "#0"},
20-
"down": {"uv": [2, 10, 1, 14], "texture": "#0"}
13+
"north": {"uv": [3.0, 0.0, 5.0, 1.5], "texture": "#can"},
14+
"east": {"uv": [0.0, 0.0, 3.0, 1.5], "texture": "#can"},
15+
"south": {"uv": [8.0, 0.0, 10.0, 1.5], "texture": "#can"},
16+
"west": {"uv": [5.0, 0.0, 8.0, 1.5], "texture": "#can"},
17+
"up": {"uv": [13.5, 0.0, 15.5, 3.0], "texture": "#can"}
2118
}
2219
},
2320
{
24-
"from": [6, 3, 5],
25-
"to": [10, 5, 11],
26-
"rotation": {"angle": 0, "axis": "y", "origin": [5, 3, 4]},
21+
"from": [10, 5, 6],
22+
"to": [11, 8, 10],
2723
"faces": {
28-
"north": {"uv": [8, 2, 12, 4], "texture": "#0"},
29-
"east": {"uv": [0, 6, 6, 8], "texture": "#0"},
30-
"south": {"uv": [4, 8, 8, 10], "texture": "#0"},
31-
"west": {"uv": [6, 6, 12, 8], "texture": "#0"},
32-
"up": {"uv": [4, 6, 0, 0], "texture": "#0"},
33-
"down": {"uv": [8, 0, 4, 6], "texture": "#0"}
24+
"north": {"uv": [2.5, 8.0, 3.0, 9.5], "texture": "#can"},
25+
"east": {"uv": [0.5, 8.0, 2.5, 9.5], "texture": "#can"},
26+
"south": {"uv": [0.0, 8.0, 0.5, 9.5], "texture": "#can"},
27+
"up": {"uv": [15.5, 0.5, 16.0, 2.5], "texture": "#can"}
3428
}
3529
},
3630
{
37-
"from": [10, 3, 6],
38-
"to": [11, 5, 10],
39-
"rotation": {"angle": 0, "axis": "y", "origin": [11, 3, 5]},
31+
"from": [5, 5, 6],
32+
"to": [6, 8, 10],
4033
"faces": {
41-
"north": {"uv": [6, 10, 7, 12], "texture": "#0"},
42-
"east": {"uv": [8, 4, 12, 6], "texture": "#0"},
43-
"south": {"uv": [7, 10, 8, 12], "texture": "#0"},
44-
"west": {"uv": [8, 8, 12, 10], "texture": "#0"},
45-
"up": {"uv": [3, 14, 2, 10], "texture": "#0"},
46-
"down": {"uv": [4, 10, 3, 14], "texture": "#0"}
34+
"north": {"uv": [5.0, 8.0, 5.5, 9.5], "texture": "#can"},
35+
"south": {"uv": [7.5, 8.0, 8.0, 9.5], "texture": "#can"},
36+
"west": {"uv": [5.5, 8.0, 7.5, 9.5], "texture": "#can"},
37+
"up": {"uv": [13.0, 0.5, 13.5, 2.5], "texture": "#can"}
4738
}
4839
},
4940
{
50-
"from": [6, 0, 5],
51-
"to": [10, 3, 11],
52-
"rotation": {"angle": 0, "axis": "y", "origin": [5, 0, 4]},
41+
"from": [6, 3, 5],
42+
"to": [10, 5, 11],
5343
"faces": {
54-
"north": {"uv": [0, 6, 2, 7.5], "texture": "#1"},
55-
"east": {"uv": [4, 0, 7, 1.5], "texture": "#1"},
56-
"south": {"uv": [2, 6, 4, 7.5], "texture": "#1"},
57-
"west": {"uv": [4, 1.5, 7, 3], "texture": "#1"},
58-
"up": {"uv": [2, 3, 0, 0], "texture": "#1"},
59-
"down": {"uv": [4, 0, 2, 3], "texture": "#1"}
44+
"north": {"uv": [3.0, 1.5, 5.0, 2.5], "texture": "#can", "tintindex": 0},
45+
"east": {"uv": [0.0, 1.5, 3.0, 2.5], "texture": "#can", "tintindex": 0},
46+
"south": {"uv": [8.0, 1.5, 10.0, 2.5], "texture": "#can", "tintindex": 0},
47+
"west": {"uv": [5.0, 1.5, 8.0, 2.5], "texture": "#can", "tintindex": 0}
6048
}
6149
},
6250
{
63-
"from": [10, 0, 6],
64-
"to": [11, 3, 10],
65-
"rotation": {"angle": 0, "axis": "y", "origin": [11, 0, 5]},
51+
"from": [10, 3, 6],
52+
"to": [11, 5, 10],
6653
"faces": {
67-
"north": {"uv": [1.5, 9, 2, 10.5], "texture": "#1"},
68-
"east": {"uv": [4, 6, 6, 7.5], "texture": "#1"},
69-
"south": {"uv": [2, 9, 2.5, 10.5], "texture": "#1"},
70-
"west": {"uv": [6, 6, 8, 7.5], "texture": "#1"},
71-
"up": {"uv": [8.5, 8, 8, 6], "texture": "#1"},
72-
"down": {"uv": [8.5, 8, 8, 10], "texture": "#1"}
54+
"north": {"uv": [2.5, 9.5, 3.0, 10.5], "texture": "#can", "tintindex": 0},
55+
"east": {"uv": [0.5, 9.5, 2.5, 10.5], "texture": "#can", "tintindex": 0},
56+
"south": {"uv": [0.0, 9.5, 0.5, 10.5], "texture": "#can", "tintindex": 0}
7357
}
7458
},
7559
{
76-
"from": [5, 0, 6],
77-
"to": [6, 3, 10],
78-
"rotation": {"angle": 0, "axis": "y", "origin": [4, 0, 5]},
60+
"from": [5, 3, 6],
61+
"to": [6, 5, 10],
7962
"faces": {
80-
"north": {"uv": [9, 2, 9.5, 3.5], "texture": "#1"},
81-
"east": {"uv": [7, 0, 9, 1.5], "texture": "#1"},
82-
"south": {"uv": [2.5, 9, 3, 10.5], "texture": "#1"},
83-
"west": {"uv": [7, 1.5, 9, 3], "texture": "#1"},
84-
"up": {"uv": [9, 8, 8.5, 6], "texture": "#1"},
85-
"down": {"uv": [9, 8, 8.5, 10], "texture": "#1"}
63+
"north": {"uv": [5.0, 9.5, 5.5, 10.5], "texture": "#can", "tintindex": 0},
64+
"south": {"uv": [7.5, 9.5, 8.0, 10.5], "texture": "#can", "tintindex": 0},
65+
"west": {"uv": [5.5, 9.5, 7.5, 10.5], "texture": "#can", "tintindex": 0}
8666
}
8767
},
8868
{
89-
"from": [6, 5, 5],
90-
"to": [10, 8, 11],
91-
"rotation": {"angle": 0, "axis": "y", "origin": [5, 5, 4]},
69+
"from": [6, 0, 5],
70+
"to": [10, 3, 11],
9271
"faces": {
93-
"north": {"uv": [7, 3, 9, 4.5], "texture": "#1"},
94-
"east": {"uv": [4, 3, 7, 4.5], "texture": "#1"},
95-
"south": {"uv": [7, 4.5, 9, 6], "texture": "#1"},
96-
"west": {"uv": [4, 4.5, 7, 6], "texture": "#1"},
97-
"up": {"uv": [2, 6, 0, 3], "texture": "#1"},
98-
"down": {"uv": [4, 3, 2, 6], "texture": "#1"}
72+
"north": {"uv": [3.0, 2.5, 5.0, 4.0], "texture": "#can"},
73+
"east": {"uv": [0.0, 2.5, 3.0, 4.0], "texture": "#can"},
74+
"south": {"uv": [8.0, 2.5, 10.0, 4.0], "texture": "#can"},
75+
"west": {"uv": [5.0, 2.5, 8.0, 4.0], "texture": "#can"},
76+
"down": {"uv": [13.5, 8.0, 15.5, 11.0], "texture": "#can"}
9977
}
10078
},
10179
{
102-
"from": [10, 5, 6],
103-
"to": [11, 8, 10],
104-
"rotation": {"angle": 0, "axis": "y", "origin": [11, 5, 5]},
80+
"from": [10, 0, 6],
81+
"to": [11, 3, 10],
10582
"faces": {
106-
"north": {"uv": [3, 9, 3.5, 10.5], "texture": "#1"},
107-
"east": {"uv": [0, 7.5, 2, 9], "texture": "#1"},
108-
"south": {"uv": [3.5, 9, 4, 10.5], "texture": "#1"},
109-
"west": {"uv": [2, 7.5, 4, 9], "texture": "#1"},
110-
"up": {"uv": [0.5, 11, 0, 9], "texture": "#1"},
111-
"down": {"uv": [9.5, 0, 9, 2], "texture": "#1"}
83+
"north": {"uv": [2.5, 10.5, 3.0, 12.0], "texture": "#can"},
84+
"east": {"uv": [0.5, 10.5, 2.5, 12.0], "texture": "#can"},
85+
"south": {"uv": [0.0, 10.5, 0.5, 12.0], "texture": "#can"},
86+
"down": {"uv": [15.5, 8.5, 16.0, 10.5], "texture": "#can"}
11287
}
11388
},
11489
{
115-
"from": [5, 5, 6],
116-
"to": [6, 8, 10],
117-
"rotation": {"angle": 0, "axis": "y", "origin": [4, 5, 5]},
90+
"from": [5, 0, 6],
91+
"to": [6, 3, 10],
11892
"faces": {
119-
"north": {"uv": [9, 3.5, 9.5, 5], "texture": "#1"},
120-
"east": {"uv": [4, 7.5, 6, 9], "texture": "#1"},
121-
"south": {"uv": [4, 9, 4.5, 10.5], "texture": "#1"},
122-
"west": {"uv": [6, 7.5, 8, 9], "texture": "#1"},
123-
"up": {"uv": [1, 11, 0.5, 9], "texture": "#1"},
124-
"down": {"uv": [1.5, 9, 1, 11], "texture": "#1"}
93+
"north": {"uv": [5.0, 10.5, 5.5, 12.0], "texture": "#can"},
94+
"south": {"uv": [7.5, 10.5, 8.0, 12.0], "texture": "#can"},
95+
"west": {"uv": [5.5, 10.5, 7.5, 12.0], "texture": "#can"},
96+
"down": {"uv": [13.0, 8.5, 13.5, 10.5], "texture": "#can"}
12597
}
12698
}
12799
],
@@ -130,13 +102,13 @@
130102
"name": "label",
131103
"origin": [8, 8, 8],
132104
"color": 0,
133-
"children": [0, 1, 2]
105+
"children": [3, 4, 5]
134106
},
135107
{
136108
"name": "can",
137109
"origin": [8, 8, 8],
138110
"color": 0,
139-
"children": [3, 4, 5, 6, 7, 8]
111+
"children": [0, 1, 2, 6, 7, 8]
140112
}
141113
]
142114
}
486 Bytes
Loading
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)