@@ -49,7 +49,8 @@ public final class %%classname%% implements DataProvider, IModel<%%classname%%>
49
49
private Path assetsDir;
50
50
private final ConcurrentHashMap<ResourceLocation, Object> MODELS =
51
51
new ConcurrentHashMap<>();// object is Bean or map, by gson
52
-
52
+ private final ConcurrentHashMap<ResourceLocation, Object> BLOCKSTATES =
53
+ new ConcurrentHashMap<>();
53
54
private <T extends Item> %%classname%% basicItem(Supplier<T> item) {
54
55
ResourceLocation key = BuiltInRegistries.ITEM.getKey(item.get()).withPrefix("item/");
55
56
MODELS.put(key, Map.of("parent", "minecraft:item/generated", "textures", Map.of(
@@ -104,39 +105,101 @@ public final class %%classname%% implements DataProvider, IModel<%%classname%%>
104
105
}
105
106
106
107
private <T extends Block> %%classname%% cubeAll(Supplier<T> block) {
107
- ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block.get()).withPrefix("block/");
108
- MODELS.put(key, Map.of(
108
+ ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block.get());
109
+ ResourceLocation blockKey = key.withPrefix("block/");
110
+ MODELS.put(blockKey, Map.of(
109
111
"parent", "minecraft:block/cube_all",
110
112
"textures", Map.of(
111
- "all", key.toString()
113
+ "all", blockKey.toString()
114
+ )
115
+ ));
116
+ BLOCKSTATES.put(key, Map.of(
117
+ "variants", Map.of(
118
+ "", Map.of(
119
+ "model", blockKey.toString()
120
+ )
112
121
)
113
122
));
114
123
return this;
115
124
}
116
125
117
126
private <T extends Block> %%classname%% stairsBlock(Supplier<T> block, String bottom, String side, String top) {
118
- ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block.get()).withPrefix("block/");
119
- MODELS.put(key, Map.of(
127
+ ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block.get());
128
+ ResourceLocation blockKey = key.withPrefix("block/");
129
+ ResourceLocation inner = blockKey.withSuffix("_inner");
130
+ ResourceLocation outer = blockKey.withSuffix("_outer");
131
+ MODELS.put(blockKey, Map.of(
120
132
"parent", "minecraft:block/stairs",
121
133
"textures", Map.of(
122
- "bottom", bottom.isEmpty() ? key .toString() : bottom,
123
- "side", side.isEmpty() ? key .toString() : side,
124
- "top", top.isEmpty() ? key .toString() : top
134
+ "bottom", bottom.isEmpty() ? blockKey .toString() : bottom,
135
+ "side", side.isEmpty() ? blockKey .toString() : side,
136
+ "top", top.isEmpty() ? blockKey .toString() : top
125
137
)));
126
- MODELS.put(key.withSuffix("_inner") , Map.of(
138
+ MODELS.put(inner , Map.of(
127
139
"parent", "minecraft:block/inner_stairs",
128
140
"textures", Map.of(
129
- "bottom", bottom.isEmpty() ? key .toString() : bottom,
130
- "side", side.isEmpty() ? key .toString() : side,
131
- "top", top.isEmpty() ? key .toString() : top
141
+ "bottom", bottom.isEmpty() ? blockKey .toString() : bottom,
142
+ "side", side.isEmpty() ? blockKey .toString() : side,
143
+ "top", top.isEmpty() ? blockKey .toString() : top
132
144
)));
133
- MODELS.put(key.withSuffix("_outer") , Map.of(
145
+ MODELS.put(outer , Map.of(
134
146
"parent", "minecraft:block/outer_stairs",
135
147
"textures", Map.of(
136
- "bottom", bottom.isEmpty() ? key .toString() : bottom,
137
- "side", side.isEmpty() ? key .toString() : side,
138
- "top", top.isEmpty() ? key .toString() : top
148
+ "bottom", bottom.isEmpty() ? blockKey .toString() : bottom,
149
+ "side", side.isEmpty() ? blockKey .toString() : side,
150
+ "top", top.isEmpty() ? blockKey .toString() : top
139
151
)));
152
+ BLOCKSTATES.put(key, Map.of(
153
+ "variants", Map.of(
154
+ "facing=east,half=bottom,shape=inner_left", Map.of(
155
+ "model", inner.toString(),
156
+ "uvlock", true,
157
+ "y", 270
158
+ ),
159
+ "facing=east,half=bottom,shape=inner_right", Map.of(
160
+ "model", inner.toString()
161
+ ),
162
+ "facing=east,half=bottom,shape=outer_left", Map.of(
163
+ "model", outer.toString(),
164
+ "uvlock", true,
165
+ "y", 270
166
+ ),
167
+ "facing=east,half=bottom,shape=outer_right", Map.of(
168
+ "model", outer.toString()
169
+ ),
170
+ "facing=east,half=bottom,shape=straight", Map.of(
171
+ "model", blockKey.toString()
172
+ ),
173
+ "facing=east,half= top,shape=inner_left", Map.of(
174
+ "model", inner.toString(),
175
+ "uvlock", true,
176
+ "x", 180
177
+ ),
178
+ "facing=east,half=top,shape=inner_right", Map.of(
179
+ "model", inner.toString(),
180
+ "uvlock", true,
181
+ "x", 180,
182
+ "y", 90
183
+ ),
184
+ "facing=east,half=top,shape=outer_left", Map.of(
185
+ "model", outer.toString(),
186
+ "uvlock", true,
187
+ "z", 180
188
+ ),
189
+ "facing=east,half=top,shape=outer_right", Map.of(
190
+ "model", outer.toString(),
191
+ "uvlock", true,
192
+ "x", 180,
193
+ "y", 90
194
+
195
+ ),
196
+ "facing=east,half= top,shape=straight", Map.of(
197
+ "model", blockKey.toString(),
198
+ "uvlock", true,
199
+ "x", 180
200
+ )
201
+ )
202
+ ));
140
203
return this;
141
204
}
142
205
@@ -212,7 +275,7 @@ public void init() {
212
275
@Override
213
276
public CompletableFuture<?> run(CachedOutput output) {
214
277
init();
215
- CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size()];
278
+ CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size() + BLOCKSTATES.size() ];
216
279
int i = 0;
217
280
for (Map.Entry<ResourceLocation, Object> entry : MODELS.entrySet()) {
218
281
ResourceLocation key = entry.getKey();
@@ -222,6 +285,14 @@ public CompletableFuture<?> run(CachedOutput output) {
222
285
futures[i] = DataProvider.saveStable(output, jsonTree, itemModel);
223
286
i++;
224
287
}
288
+ for(Map.Entry<ResourceLocation, Object> entry : BLOCKSTATES.entrySet()) {
289
+ ResourceLocation key = entry.getKey();
290
+ Object object = entry.getValue();
291
+ Path states = assetsDir.resolve(key.getNamespace()).resolve("blockstates").resolve(key.getPath() + ".json");
292
+ JsonElement jsonTree = GSON.toJsonTree(object);
293
+ futures[i] = DataProvider.saveStable(output, jsonTree, states);
294
+ i++;
295
+ }
225
296
return CompletableFuture.allOf(futures);
226
297
}
227
298
0 commit comments