Skip to content

Commit

Permalink
Replace interface patches with interface injection
Browse files Browse the repository at this point in the history
  • Loading branch information
ApexModder committed Dec 15, 2024
1 parent 169436e commit f58d0ff
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 46 deletions.

This file was deleted.

46 changes: 32 additions & 14 deletions patches/net/minecraft/client/data/models/ModelProvider.java.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
--- a/net/minecraft/client/data/models/ModelProvider.java
+++ b/net/minecraft/client/data/models/ModelProvider.java
@@ -30,24 +_,62 @@
import net.neoforged.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
-public class ModelProvider implements DataProvider {
+public class ModelProvider implements DataProvider, net.neoforged.neoforge.common.extensions.IModelProviderExtension {
@@ -34,26 +_,64 @@
private final PackOutput.PathProvider blockStatePathProvider;
private final PackOutput.PathProvider itemInfoPathProvider;
private final PackOutput.PathProvider modelPathProvider;
Expand Down Expand Up @@ -68,6 +63,15 @@
modelprovider$blockstategeneratorcollector.validate();
modelprovider$iteminfocollector.finalizeAndValidate();
return CompletableFuture.allOf(
- modelprovider$blockstategeneratorcollector.save(p_387857_, this.blockStatePathProvider),
- modelprovider$simplemodelcollector.save(p_387857_, this.modelPathProvider),
- modelprovider$iteminfocollector.save(p_387857_, this.itemInfoPathProvider)
+ modelprovider$blockstategeneratorcollector.save(p_387857_, this.blockStatePathProvider),
+ modelprovider$simplemodelcollector.save(p_387857_, this.modelPathProvider),
+ modelprovider$iteminfocollector.save(p_387857_, this.itemInfoPathProvider)
);
}

@@ -63,12 +_,22 @@

@Override
Expand All @@ -92,18 +96,20 @@

public void accept(BlockStateGenerator p_388748_) {
Block block = p_388748_.getBlock();
@@ -79,9 +_,9 @@
@@ -79,10 +_,10 @@
}

public void validate() {
- Stream<Holder.Reference<Block>> stream = BuiltInRegistries.BLOCK.listElements().filter(p_388333_ -> true);
+ Stream<? extends Holder<Block>> stream = knownBlocks.get();
List<ResourceLocation> list = stream.filter(p_386843_ -> !this.generators.containsKey(p_386843_.value()))
- .map(p_386823_ -> p_386823_.key().location())
+ .map(p_386823_ -> p_386823_.unwrapKey().orElseThrow().location())
.toList();
- .toList();
+ .map(p_386823_ -> p_386823_.unwrapKey().orElseThrow().location())
+ .toList();
if (!list.isEmpty()) {
throw new IllegalStateException("Missing blockstate definitions for: " + list);
}
@@ -97,6 +_,16 @@
static class ItemInfoCollector implements ItemModelOutput {
private final Map<Item, ClientItem> itemInfos = new HashMap<>();
Expand All @@ -130,16 +136,28 @@
if (!this.copies.containsKey(p_388426_)) {
if (p_388426_ instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) {
ResourceLocation resourcelocation = ModelLocationUtils.getModelLocation(blockitem.getBlock());
@@ -132,10 +_,9 @@
@@ -132,11 +_,10 @@
this.register(p_386494_, clientitem);
}
});
- List<ResourceLocation> list = BuiltInRegistries.ITEM
- .listElements()
+ List<ResourceLocation> list = knownItems.get()
.filter(p_388636_ -> !this.itemInfos.containsKey(p_388636_.value()))
- .filter(p_388636_ -> !this.itemInfos.containsKey(p_388636_.value()))
- .map(p_388278_ -> p_388278_.key().location())
+ .map(p_388278_ -> p_388278_.unwrapKey().orElseThrow().location())
.toList();
- .toList();
+ List<ResourceLocation> list = knownItems.get()
+ .filter(p_388636_ -> !this.itemInfos.containsKey(p_388636_.value()))
+ .map(p_388278_ -> p_388278_.unwrapKey().orElseThrow().location())
+ .toList();
if (!list.isEmpty()) {
throw new IllegalStateException("Missing item model definitions for: " + list);
}
@@ -144,7 +_,7 @@

public CompletableFuture<?> save(CachedOutput p_387552_, PackOutput.PathProvider p_388501_) {
return DataProvider.saveAll(
- p_387552_, ClientItem.CODEC, p_388594_ -> p_388501_.json(p_388594_.builtInRegistryHolder().key().location()), this.itemInfos
+ p_387552_, ClientItem.CODEC, p_388594_ -> p_388501_.json(p_388594_.builtInRegistryHolder().key().location()), this.itemInfos
);
}
}

This file was deleted.

14 changes: 13 additions & 1 deletion src/main/resources/META-INF/injected-interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"net/minecraft/client/renderer/block/model/BlockModel": [
"net/neoforged/neoforge/client/model/ExtendedUnbakedModel"
],
"net/minecraft/client/data/models/BlockModelGenerators": [
"net/neoforged/neoforge/client/extensions/IBlockModelGeneratorsExtension"
],
"net/minecraft/client/renderer/block/model/ItemModelGenerator": [
"net/neoforged/neoforge/client/model/ExtendedUnbakedModel"
],
Expand Down Expand Up @@ -225,7 +228,7 @@
"net/minecraft/world/level/material/FluidState": [
"net/neoforged/neoforge/common/extensions/IFluidStateExtension"
],

"com/mojang/blaze3d/vertex/VertexFormatElement$Usage": [
"net/neoforged/fml/common/asm/enumextension/IExtensibleEnum"
],
Expand Down Expand Up @@ -270,5 +273,14 @@
],
"net/minecraft/world/level/biome/BiomeSpecialEffects$GrassColorModifier": [
"net/neoforged/fml/common/asm/enumextension/IExtensibleEnum"
],
"net/minecraft/client/data/models/model/TexturedModel": [
"net/neoforged/neoforge/client/extensions/ITexturedModelExtension"
],
"net/minecraft/client/data/models/ModelProvider": [
"net/neoforged/neoforge/common/extensions/IModelProviderExtension"
],
"net/minecraft/client/data/models/model/TexturedModel$Provider": [
"net/neoforged/neoforge/client/extensions/ITexturedModelExtension$Provider"
]
}

0 comments on commit f58d0ff

Please sign in to comment.