-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7320b9
commit 408ec8a
Showing
13 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
patches/net/minecraft/client/data/models/ModelProvider.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- a/net/minecraft/client/data/models/ModelProvider.java | ||
+++ b/net/minecraft/client/data/models/ModelProvider.java | ||
@@ -34,20 +_,38 @@ | ||
private final PackOutput.PathProvider blockStatePathProvider; | ||
private final PackOutput.PathProvider itemInfoPathProvider; | ||
private final PackOutput.PathProvider modelPathProvider; | ||
+ public final String modId; | ||
|
||
- public ModelProvider(PackOutput p_388260_) { | ||
+ public ModelProvider(PackOutput p_388260_, String modId) { | ||
this.blockStatePathProvider = p_388260_.createPathProvider(PackOutput.Target.RESOURCE_PACK, "blockstates"); | ||
this.itemInfoPathProvider = p_388260_.createPathProvider(PackOutput.Target.RESOURCE_PACK, "items"); | ||
this.modelPathProvider = p_388260_.createPathProvider(PackOutput.Target.RESOURCE_PACK, "models"); | ||
+ this.modId = modId; | ||
+ } | ||
+ | ||
+ /** | ||
+ * @deprecated Use modid sensitive version ({@link #ModelProvider(PackOutput, String)}) | ||
+ */ | ||
+ @Deprecated | ||
+ public ModelProvider(PackOutput p_388260_) { | ||
+ this(p_388260_, ResourceLocation.DEFAULT_NAMESPACE); | ||
+ } | ||
+ | ||
+ protected void registerModels(BlockModelGenerators blockModels, ItemModelGenerators itemModels) { | ||
+ blockModels.run(); | ||
+ itemModels.run(); | ||
+ } | ||
+ | ||
+ protected boolean shouldGenerate(Holder.Reference<?> holder) { | ||
+ return holder.key().location().getNamespace().equals(modId); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<?> run(CachedOutput p_387857_) { | ||
- ModelProvider.ItemInfoCollector modelprovider$iteminfocollector = new ModelProvider.ItemInfoCollector(); | ||
- ModelProvider.BlockStateGeneratorCollector modelprovider$blockstategeneratorcollector = new ModelProvider.BlockStateGeneratorCollector(); | ||
+ ModelProvider.ItemInfoCollector modelprovider$iteminfocollector = new ModelProvider.ItemInfoCollector(this); | ||
+ ModelProvider.BlockStateGeneratorCollector modelprovider$blockstategeneratorcollector = new ModelProvider.BlockStateGeneratorCollector(this); | ||
ModelProvider.SimpleModelCollector modelprovider$simplemodelcollector = new ModelProvider.SimpleModelCollector(); | ||
- new BlockModelGenerators(modelprovider$blockstategeneratorcollector, modelprovider$iteminfocollector, modelprovider$simplemodelcollector).run(); | ||
- new ItemModelGenerators(modelprovider$iteminfocollector, modelprovider$simplemodelcollector).run(); | ||
+ registerModels(new BlockModelGenerators(modelprovider$blockstategeneratorcollector, modelprovider$iteminfocollector, modelprovider$simplemodelcollector), new ItemModelGenerators(modelprovider$iteminfocollector, modelprovider$simplemodelcollector)); | ||
modelprovider$blockstategeneratorcollector.validate(); | ||
modelprovider$iteminfocollector.finalizeAndValidate(); | ||
return CompletableFuture.allOf( | ||
@@ -69,6 +_,11 @@ | ||
@OnlyIn(Dist.CLIENT) | ||
static class BlockStateGeneratorCollector implements Consumer<BlockStateGenerator> { | ||
private final Map<Block, BlockStateGenerator> generators = new HashMap<>(); | ||
+ private final ModelProvider provider; | ||
+ | ||
+ private BlockStateGeneratorCollector(ModelProvider provider) { | ||
+ this.provider = provider; | ||
+ } | ||
|
||
public void accept(BlockStateGenerator p_388748_) { | ||
Block block = p_388748_.getBlock(); | ||
@@ -79,7 +_,7 @@ | ||
} | ||
|
||
public void validate() { | ||
- Stream<Holder.Reference<Block>> stream = BuiltInRegistries.BLOCK.listElements().filter(p_388333_ -> true); | ||
+ Stream<Holder.Reference<Block>> stream = BuiltInRegistries.BLOCK.listElements().filter(provider::shouldGenerate); | ||
List<ResourceLocation> list = stream.filter(p_386843_ -> !this.generators.containsKey(p_386843_.value())) | ||
.map(p_386823_ -> p_386823_.key().location()) | ||
.toList(); | ||
@@ -97,6 +_,11 @@ | ||
static class ItemInfoCollector implements ItemModelOutput { | ||
private final Map<Item, ClientItem> itemInfos = new HashMap<>(); | ||
private final Map<Item, Item> copies = new HashMap<>(); | ||
+ private final ModelProvider provider; | ||
+ | ||
+ private ItemInfoCollector(ModelProvider provider) { | ||
+ this.provider = provider; | ||
+ } | ||
|
||
@Override | ||
public void accept(Item p_387063_, ItemModel.Unbaked p_388578_) { | ||
@@ -116,7 +_,7 @@ | ||
} | ||
|
||
public void finalizeAndValidate() { | ||
- BuiltInRegistries.ITEM.forEach(p_388426_ -> { | ||
+ BuiltInRegistries.ITEM.listElements().filter(provider::shouldGenerate).map(Holder::value).forEach(p_388426_ -> { | ||
if (!this.copies.containsKey(p_388426_)) { | ||
if (p_388426_ instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) { | ||
ResourceLocation resourcelocation = ModelLocationUtils.getModelLocation(blockitem.getBlock()); | ||
@@ -134,6 +_,7 @@ | ||
}); | ||
List<ResourceLocation> list = BuiltInRegistries.ITEM | ||
.listElements() | ||
+ .filter(provider::shouldGenerate) | ||
.filter(p_388636_ -> !this.itemInfos.containsKey(p_388636_.value())) | ||
.map(p_388278_ -> p_388278_.key().location()) | ||
.toList(); |
18 changes: 18 additions & 0 deletions
18
patches/net/minecraft/client/data/models/model/ModelLocationUtils.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- a/net/minecraft/client/data/models/model/ModelLocationUtils.java | ||
+++ b/net/minecraft/client/data/models/model/ModelLocationUtils.java | ||
@@ -11,11 +_,13 @@ | ||
public class ModelLocationUtils { | ||
@Deprecated | ||
public static ResourceLocation decorateBlockModelLocation(String p_388520_) { | ||
- return ResourceLocation.withDefaultNamespace("block/" + p_388520_); | ||
+ // NeoForge: Use ResourceLocation.parse to support modded paths | ||
+ return ResourceLocation.parse(p_388520_).withPrefix("block/"); | ||
} | ||
|
||
public static ResourceLocation decorateItemModelLocation(String p_387226_) { | ||
- return ResourceLocation.withDefaultNamespace("item/" + p_387226_); | ||
+ // NeoForge: Use ResourceLocation.parse to support modded paths | ||
+ return ResourceLocation.parse(p_387226_).withPrefix("item/"); | ||
} | ||
|
||
public static ResourceLocation getModelLocation(Block p_387758_, String p_388221_) { |
29 changes: 29 additions & 0 deletions
29
patches/net/minecraft/client/data/models/model/ModelTemplates.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- a/net/minecraft/client/data/models/model/ModelTemplates.java | ||
+++ b/net/minecraft/client/data/models/model/ModelTemplates.java | ||
@@ -203,18 +_,22 @@ | ||
} | ||
|
||
public static ModelTemplate create(String p_386521_, TextureSlot... p_388561_) { | ||
- return new ModelTemplate(Optional.of(ResourceLocation.withDefaultNamespace("block/" + p_386521_)), Optional.empty(), p_388561_); | ||
+ // NeoForge: Support modded paths | ||
+ return new ModelTemplate(Optional.of(ModelLocationUtils.decorateBlockModelLocation(p_386521_)), Optional.empty(), p_388561_); | ||
} | ||
|
||
public static ModelTemplate createItem(String p_388248_, TextureSlot... p_386756_) { | ||
- return new ModelTemplate(Optional.of(ResourceLocation.withDefaultNamespace("item/" + p_388248_)), Optional.empty(), p_386756_); | ||
+ // NeoForge: Support modded paths | ||
+ return new ModelTemplate(Optional.of(ModelLocationUtils.decorateItemModelLocation(p_388248_)), Optional.empty(), p_386756_); | ||
} | ||
|
||
public static ModelTemplate createItem(String p_386727_, String p_387707_, TextureSlot... p_387856_) { | ||
- return new ModelTemplate(Optional.of(ResourceLocation.withDefaultNamespace("item/" + p_386727_)), Optional.of(p_387707_), p_387856_); | ||
+ // NeoForge: Support modded paths | ||
+ return new ModelTemplate(Optional.of(ModelLocationUtils.decorateItemModelLocation(p_386727_)), Optional.of(p_387707_), p_387856_); | ||
} | ||
|
||
public static ModelTemplate create(String p_386833_, String p_386662_, TextureSlot... p_387086_) { | ||
- return new ModelTemplate(Optional.of(ResourceLocation.withDefaultNamespace("block/" + p_386833_)), Optional.of(p_386662_), p_387086_); | ||
+ // NeoForge: Support modded paths | ||
+ return new ModelTemplate(Optional.of(ModelLocationUtils.decorateBlockModelLocation(p_386833_)), Optional.of(p_386662_), p_387086_); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
patches/net/minecraft/client/data/models/model/TexturedModel.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- a/net/minecraft/client/data/models/model/TexturedModel.java | ||
+++ b/net/minecraft/client/data/models/model/TexturedModel.java | ||
@@ -65,7 +_,7 @@ | ||
return this.template.createWithSuffix(p_388536_, p_387320_, this.mapping, p_387896_); | ||
} | ||
|
||
- public static TexturedModel.Provider createDefault(Function<Block, TextureMapping> p_386771_, ModelTemplate p_388272_) { | ||
+ private static TexturedModel.Provider createDefault(Function<Block, TextureMapping> p_386771_, ModelTemplate p_388272_) { | ||
return p_386939_ -> new TexturedModel(p_386771_.apply(p_386939_), p_388272_); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
.../resources/assets/neotests_test_model_generators/blockstates/vanilla_model_gen_block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "neotests_test_model_generators:block/vanilla_model_gen_block" | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...erated/resources/assets/neotests_test_model_generators/items/vanilla_model_gen_block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"model": { | ||
"type": "minecraft:model", | ||
"model": "neotests_test_model_generators:block/vanilla_model_gen_block" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...nerated/resources/assets/neotests_test_model_generators/items/vanilla_model_gen_item.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"model": { | ||
"type": "minecraft:model", | ||
"model": "neotests_test_model_generators:item/vanilla_model_gen_item" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...resources/assets/neotests_test_model_generators/models/block/vanilla_model_gen_block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cube_all", | ||
"textures": { | ||
"all": "neotests_test_model_generators:block/vanilla_model_gen_block" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...d/resources/assets/neotests_test_model_generators/models/item/vanilla_model_gen_item.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "neotests_test_model_generators:item/vanilla_model_gen_item" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+371 Bytes
...ssets/neotests_test_model_generators/textures/block/vanilla_model_gen_block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+371 Bytes
.../assets/neotests_test_model_generators/textures/item/vanilla_model_gen_item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.