Skip to content

Commit

Permalink
Added option to disable block item info auto generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Dec 19, 2024
1 parent b53854d commit ca9c8f0
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions common/src/main/java/glitchcore/data/ModelProviderBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ public abstract class ModelProviderBase implements DataProvider
private final PackOutput.PathProvider itemInfoPathProvider;
private final PackOutput.PathProvider modelPathProvider;
private final String modId;
private final boolean autogenBlockItemInfos;

public ModelProviderBase(PackOutput output, String modId) {
public ModelProviderBase(PackOutput output, String modId, boolean autogenBlockItemInfos) {
this.blockStatePathProvider = output.createPathProvider(PackOutput.Target.RESOURCE_PACK, "blockstates");
this.itemInfoPathProvider = output.createPathProvider(PackOutput.Target.RESOURCE_PACK, "items");
this.modelPathProvider = output.createPathProvider(PackOutput.Target.RESOURCE_PACK, "models");
this.modId = modId;
this.autogenBlockItemInfos = autogenBlockItemInfos;
}

public ModelProviderBase(PackOutput output, String modId) {
this(output, modId, true)
}

abstract protected BlockModelGenerators createBlockModelGenerators(Consumer<BlockStateGenerator> blockStateOutput, ItemModelOutput itemModelOutput, BiConsumer<ResourceLocation, ModelInstance> modelOutput);
Expand Down Expand Up @@ -121,14 +127,17 @@ public void copy(Item p_386920_, Item p_386789_) {

public void finalizeAndValidate()
{
BuiltInRegistries.ITEM.listElements().filter(ModelProviderBase.this::isModded).forEach(p_388426_ -> {
if (!this.copies.containsKey(p_388426_)) {
if (p_388426_.value() instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) {
ResourceLocation resourcelocation = ModelLocationUtils.getModelLocation(blockitem.getBlock());
this.accept(blockitem, ItemModelUtils.plainModel(resourcelocation));
if (ModelProviderBase.this.autogenBlockItemInfos)
{
BuiltInRegistries.ITEM.listElements().filter(ModelProviderBase.this::isModded).forEach(p_388426_ -> {
if (!this.copies.containsKey(p_388426_)) {
if (p_388426_.value() instanceof BlockItem blockitem && !this.itemInfos.containsKey(blockitem)) {
ResourceLocation resourcelocation = ModelLocationUtils.getModelLocation(blockitem.getBlock());
this.accept(blockitem, ItemModelUtils.plainModel(resourcelocation));
}
}
}
});
});
}
this.copies.forEach((p_386494_, p_386575_) -> {
ClientItem clientitem = this.itemInfos.get(p_386575_);
if (clientitem == null) {
Expand Down

0 comments on commit ca9c8f0

Please sign in to comment.