Skip to content

Commit

Permalink
Add method to allow generating family models for existing blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ApexModder committed Dec 20, 2024
1 parent f9eb871 commit bc5f055
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/net/minecraft/client/data/models/BlockModelGenerators.java
+++ b/net/minecraft/client/data/models/BlockModelGenerators.java
@@ -5819,4 +_,16 @@
return this;
}
}
+
+ /**
+ * Neo: create a {@link BlockModelGenerators.BlockFamilyProvider} which re-uses the existing model of the given full
+ * block instead of creating a model and blockstate file for it. Intended for use cases where the full block is
+ * separately generated or otherwise exists such as when a dummy {@link BlockFamily} is used to create additional
+ * variants for existing vanilla block families
+ */
+ public BlockModelGenerators.BlockFamilyProvider familyWithExistingFullBlock(Block fullBlock) {
+ var provider = new BlockModelGenerators.BlockFamilyProvider(TextureMapping.cube(fullBlock));
+ provider.fullBlock = ModelLocationUtils.getModelLocation(fullBlock);
+ return provider;
+ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.client.data.models.BlockModelGenerators;
import net.minecraft.client.data.models.ItemModelGenerators;
import net.minecraft.client.data.models.ModelProvider;
import net.minecraft.client.data.models.model.TexturedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
Expand Down Expand Up @@ -94,8 +93,7 @@ static void woodlessFenceGate(final DynamicTest test, final RegistrationHelper r
@Override
protected void registerModels(BlockModelGenerators blockModels, ItemModelGenerators itemModels) {
var family = new BlockFamily.Builder(Blocks.IRON_BLOCK).fenceGate(gate.value()).getFamily();
var textureModel = TexturedModel.CUBE.get(Blocks.IRON_BLOCK);
blockModels.new BlockFamilyProvider(textureModel.getMapping()).generateFor(family);
blockModels.familyWithExistingFullBlock(family.getBaseBlock()).generateFor(family);
}

@Override
Expand Down

0 comments on commit bc5f055

Please sign in to comment.