Skip to content

Commit 9898c9a

Browse files
committed
模型生成添加方块状态的生成预选
1 parent 5197bc5 commit 9898c9a

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

processor/src/main/java/org/polaris2023/utils/Codes.java

+22-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public final class %%classname%% implements DataProvider, IModel<%%classname%%>
4949
private Path assetsDir;
5050
private final ConcurrentHashMap<ResourceLocation, Object> MODELS =
5151
new ConcurrentHashMap<>();// object is Bean or map, by gson
52-
52+
private final ConcurrentHashMap<ResourceLocation, Object> BLOCKSTATES =
53+
new ConcurrentHashMap<>();
5354
private <T extends Item> %%classname%% basicItem(Supplier<T> item) {
5455
ResourceLocation key = BuiltInRegistries.ITEM.getKey(item.get()).withPrefix("item/");
5556
MODELS.put(key, Map.of("parent", "minecraft:item/generated", "textures", Map.of(
@@ -104,11 +105,19 @@ public final class %%classname%% implements DataProvider, IModel<%%classname%%>
104105
}
105106
106107
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(
109111
"parent", "minecraft:block/cube_all",
110112
"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+
)
112121
)
113122
));
114123
return this;
@@ -212,7 +221,7 @@ public void init() {
212221
@Override
213222
public CompletableFuture<?> run(CachedOutput output) {
214223
init();
215-
CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size()];
224+
CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size() + BLOCKSTATES.size()];
216225
int i = 0;
217226
for (Map.Entry<ResourceLocation, Object> entry : MODELS.entrySet()) {
218227
ResourceLocation key = entry.getKey();
@@ -222,6 +231,14 @@ public CompletableFuture<?> run(CachedOutput output) {
222231
futures[i] = DataProvider.saveStable(output, jsonTree, itemModel);
223232
i++;
224233
}
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+
}
225242
return CompletableFuture.allOf(futures);
226243
}
227244
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.polaris2023.wild_wind.common.dyed;
2+
3+
/**
4+
* @author : baka4n
5+
* {@code @Date : 2025/02/21 18:18:36}
6+
*/
7+
public class ModDyeColors {
8+
9+
}

src/main/java/org/polaris2023/wild_wind/common/entity/Piranha.java

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.polaris2023.wild_wind.common.entity.goal.piranha.PiranhaAttackGoal;
1616
import org.polaris2023.wild_wind.common.init.items.entity.ModMobBuckets;
1717

18-
import java.util.LinkedList;
1918
import java.util.List;
2019

2120
public class Piranha extends AbstractSchoolingFish {

src/main/java/org/polaris2023/wild_wind/common/init/items/ModBaseItems.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* {@code @Date : 2025/02/12 20:19:42}
2222
*/
2323
@BasicItem
24-
public enum ModBaseItems implements Supplier<Item>, ItemLike {
24+
public enum ModBaseItems implements Supplier<Item>, ItemLike {
2525
@I18n(en_us = "Glow Powder", zh_cn = "萤光粉末", zh_tw = "螢光粉末")
2626
GLOW_POWDER,
2727
@I18n(en_us = "Apple Cake", zh_cn = "苹果派", zh_tw = "蘋果派")
@@ -36,6 +36,8 @@ public enum ModBaseItems implements Supplier<Item>, ItemLike {
3636
SPIDER_EGG(STACK_TO_1),
3737
@I18n(en_us = "Spider Mucosa", zh_cn = "蛛丝壁膜", zh_tw = "蛛絲壁膜")
3838
SPIDER_MUCOSA,
39+
@I18n(en_us = "salt", zh_cn = "盐", zh_tw = "鹽")
40+
SALT(STACK_TO_SNOW)
3941
;
4042
public final DeferredItem<Item> entry;
4143
ModBaseItems() {

src/main/java/org/polaris2023/wild_wind/datagen/loot/ModBlockLootSubProvider.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.polaris2023.wild_wind.common.init.ModBlocks;
1010
import org.polaris2023.wild_wind.common.init.ModInitializer;
1111
import org.polaris2023.wild_wind.common.init.ModItems;
12+
import org.polaris2023.wild_wind.common.init.items.ModBaseItems;
1213
import org.polaris2023.wild_wind.datagen.ModBlockFamilies;
1314

1415
import java.util.Set;
@@ -39,8 +40,8 @@ public void generate() {
3940
this.dropSelf(ModBlocks.CONCRETE.get());
4041
this.dropSelf(ModBlocks.GLAZED_TERRACOTTA.get());
4142
this.dropSelf(ModBlocks.SALT_BLOCK.get());
42-
this.dropOther(ModBlocks.SALT_ORE.get(), ModItems.SALT.get());
43-
this.dropOther(ModBlocks.DEEPSLATE_SALT_ORE.get(), ModItems.SALT.get());
43+
this.dropOther(ModBlocks.SALT_ORE.get(), ModBaseItems.SALT.get());
44+
this.dropOther(ModBlocks.DEEPSLATE_SALT_ORE.get(), ModBaseItems.SALT.get());
4445
this.dropSelf(ModBlocks.AZALEA_LOG.get());
4546
this.dropSelf(ModBlocks.STRIPPED_AZALEA_LOG.get());
4647
this.dropSelf(ModBlocks.AZALEA_WOOD.get());

0 commit comments

Comments
 (0)