@@ -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,11 +105,19 @@ 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(blockKry, 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;
@@ -212,7 +221,7 @@ public void init() {
212
221
@Override
213
222
public CompletableFuture<?> run(CachedOutput output) {
214
223
init();
215
- CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size()];
224
+ CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size() + BLOCKSTATES.size() ];
216
225
int i = 0;
217
226
for (Map.Entry<ResourceLocation, Object> entry : MODELS.entrySet()) {
218
227
ResourceLocation key = entry.getKey();
@@ -222,6 +231,14 @@ public CompletableFuture<?> run(CachedOutput output) {
222
231
futures[i] = DataProvider.saveStable(output, jsonTree, itemModel);
223
232
i++;
224
233
}
234
+ for(Map.Entry<ResourceLocation, Object> entry : BLOCKSTATES.entrySet()) {
235
+ ResourceLocation key = entry.getKey();
236
+ Object object = entry.getValue();
237
+ Path states = assetsDir.resolve(key.getNamespace()).resolve("blockstates").resolve(key.getPath() + ".json");
238
+ JsonElement jsonTree = GSON.toJsonTree(object);
239
+ futures[i] = DataProvider.saveStable(output, jsonTree, states);
240
+ i++;
241
+ }
225
242
return CompletableFuture.allOf(futures);
226
243
}
227
244
0 commit comments