Skip to content

Commit dcc821b

Browse files
authored
Merge pull request #82 from Polaris-Bears-MC/main
帮助拉取上游更新避免出错
2 parents e5b7bca + 7e3b209 commit dcc821b

File tree

96 files changed

+442
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+442
-349
lines changed

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

+89-18
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,39 +105,101 @@ 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(blockKey, 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;
115124
}
116125
117126
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(
120132
"parent", "minecraft:block/stairs",
121133
"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
125137
)));
126-
MODELS.put(key.withSuffix("_inner"), Map.of(
138+
MODELS.put(inner, Map.of(
127139
"parent", "minecraft:block/inner_stairs",
128140
"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
132144
)));
133-
MODELS.put(key.withSuffix("_outer"), Map.of(
145+
MODELS.put(outer, Map.of(
134146
"parent", "minecraft:block/outer_stairs",
135147
"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
139151
)));
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+
));
140203
return this;
141204
}
142205
@@ -212,7 +275,7 @@ public void init() {
212275
@Override
213276
public CompletableFuture<?> run(CachedOutput output) {
214277
init();
215-
CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size()];
278+
CompletableFuture<?>[] futures = new CompletableFuture[MODELS.size() + BLOCKSTATES.size()];
216279
int i = 0;
217280
for (Map.Entry<ResourceLocation, Object> entry : MODELS.entrySet()) {
218281
ResourceLocation key = entry.getKey();
@@ -222,6 +285,14 @@ public CompletableFuture<?> run(CachedOutput output) {
222285
futures[i] = DataProvider.saveStable(output, jsonTree, itemModel);
223286
i++;
224287
}
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+
}
225296
return CompletableFuture.allOf(futures);
226297
}
227298

src/main/java/org/polaris2023/wild_wind/client/WildWindClientEventHandler.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
package org.polaris2023.wild_wind.client;
22

3-
import net.minecraft.client.color.block.BlockColor;
4-
import net.minecraft.core.BlockPos;
53
import net.minecraft.util.FastColor;
64
import net.minecraft.world.item.Items;
7-
import net.minecraft.world.item.SpawnEggItem;
8-
import net.minecraft.world.level.BlockAndTintGetter;
9-
import net.minecraft.world.level.block.entity.BlockEntity;
10-
import net.minecraft.world.level.block.state.BlockState;
115
import net.neoforged.api.distmarker.Dist;
126
import net.neoforged.bus.api.EventPriority;
137
import net.neoforged.bus.api.SubscribeEvent;
148
import net.neoforged.fml.common.EventBusSubscriber;
159
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
1610
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
17-
import org.jetbrains.annotations.Nullable;
1811
import org.polaris2023.wild_wind.client.entity.abstracts.ModMobRenderer;
1912
import org.polaris2023.wild_wind.client.entity.firefly.FireflyModel;
2013
import org.polaris2023.wild_wind.client.entity.piranha.PiranhaModel;
2114
import org.polaris2023.wild_wind.client.entity.trout.TroutModel;
22-
import org.polaris2023.wild_wind.common.block.WoolBlock;
23-
import org.polaris2023.wild_wind.common.block.entity.WoolBlockEntity;
2415
import org.polaris2023.wild_wind.common.init.ModBlocks;
2516
import org.polaris2023.wild_wind.common.init.ModComponents;
2617
import org.polaris2023.wild_wind.common.init.ModEntities;
@@ -38,14 +29,7 @@ public static void registerSlimeColor(RegisterColorHandlersEvent.Item event) {
3829

3930
@SubscribeEvent
4031
public static void registerBlockColor(RegisterColorHandlersEvent.Block event) {
41-
event.register((state, level, pos, tinIndex) -> {
42-
if (level == null || pos == null) {
43-
return FastColor.ARGB32.opaque(0);
44-
}
45-
WoolBlockEntity woolTile = (WoolBlockEntity) level.getBlockEntity(pos);
46-
if (woolTile == null) return FastColor.ARGB32.opaque(0);
47-
return FastColor.ARGB32.opaque(woolTile.rgb);
48-
}, ModBlocks.WOOL.get());
32+
4933
}
5034

5135
@SubscribeEvent

0 commit comments

Comments
 (0)