Skip to content

Commit

Permalink
Let ModelProvider subclass decide which blocks are relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD authored and ApexModder committed Dec 3, 2024
1 parent fb4a95d commit 923a4a7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
29 changes: 21 additions & 8 deletions patches/net/minecraft/data/models/ModelProvider.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,39 @@
}

@Override
@@ -52,19 +_,18 @@
@@ -52,19 +_,14 @@
}
};
Consumer<Item> consumer1 = set::add;
- new BlockModelGenerators(consumer, biconsumer, consumer1).run();
- new ItemModelGenerators(biconsumer).run();
+ registerModels(new BlockModelGenerators(consumer, biconsumer, consumer1, this.modId), new ItemModelGenerators(biconsumer, this.modId));
List<Block> list = BuiltInRegistries.BLOCK
.entrySet()
.stream()
- List<Block> list = BuiltInRegistries.BLOCK
- .entrySet()
- .stream()
- .filter(p_300706_ -> true)
+ .filter(p_300706_ -> p_300706_.getKey().location().getNamespace().equals(modId))
.map(Entry::getValue)
- .map(Entry::getValue)
+ registerModels(new BlockModelGenerators(consumer, biconsumer, consumer1, this.modId), new ItemModelGenerators(biconsumer, this.modId));
+ List<Block> list = getKnownBlocks()
.filter(p_125117_ -> !map.containsKey(p_125117_))
.toList();
if (!list.isEmpty()) {
throw new IllegalStateException("Missing blockstate definitions for: " + list);
} else {
- BuiltInRegistries.BLOCK.forEach(p_125128_ -> {
+ BuiltInRegistries.BLOCK.stream().filter(block -> BuiltInRegistries.BLOCK.getKey(block).getNamespace().equals(modId)).forEach(p_125128_ -> {
+ getKnownBlocks().forEach(p_125128_ -> {
Item item = Item.BY_BLOCK.get(p_125128_);
if (item != null) {
if (set.contains(item)) {
@@ -95,5 +_,12 @@
@Override
public String getName() {
return "Model Definitions";
+ }
+
+ protected java.util.stream.Stream<Block> getKnownBlocks() {
+ return BuiltInRegistries.BLOCK.entrySet()
+ .stream()
+ .filter(block -> block.getKey().location().getNamespace().equals(modId))
+ .map(Entry::getValue);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,5 @@ public net.minecraft.data.models.model.ModelTemplate *
public net.minecraft.data.models.model.TexturedModel <init>(Lnet/minecraft/data/models/model/TextureMapping;Lnet/minecraft/data/models/model/ModelTemplate;)V
public net.minecraft.data.models.model.TexturedModel createDefault(Ljava/util/function/Function;Lnet/minecraft/data/models/model/ModelTemplate;)Lnet/minecraft/data/models/model/TexturedModel$Provider;
public net.minecraft.data.models.model.TextureSlot create(Ljava/lang/String;)Lnet/minecraft/data/models/model/TextureSlot;
public net.minecraft.data.models.model.TextureSlot create(Ljava/lang/String;Lnet/minecraft/data/models/model/TextureSlot;)Lnet/minecraft/data/models/model/TextureSlot;
public net.minecraft.data.models.model.TextureSlot create(Ljava/lang/String;Lnet/minecraft/data/models/model/TextureSlot;)Lnet/minecraft/data/models/model/TextureSlot;
public-f net.minecraft.data.models.ModelProvider getName()Ljava/lang/String;

0 comments on commit 923a4a7

Please sign in to comment.