Skip to content

Commit

Permalink
Return the break texture for block entity models on BlockStateAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Jan 24, 2024
1 parent 0a9da0a commit a6168d0
Showing 1 changed file with 14 additions and 11 deletions.
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.commands.arguments.blocks.BlockStateParser;
Expand Down Expand Up @@ -306,21 +307,23 @@ public HashMap<String, Set<String>> getTextures() {
HashMap<String, Set<String>> map = new HashMap<>();

RenderShape renderShape = blockState.getRenderShape();
if (renderShape != RenderShape.MODEL)
return map;

BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();
BakedModel bakedModel = blockRenderer.getBlockModel(blockState);
RandomSource randomSource = RandomSource.create();
long seed = 42L;
if (renderShape == RenderShape.MODEL) {
BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();

for (Direction direction : Direction.values())
map.put(direction.name(), getTexturesForFace(blockState, direction, randomSource, bakedModel, seed));
map.put("NONE", getTexturesForFace(blockState, null, randomSource, bakedModel, seed));
BakedModel bakedModel = blockRenderer.getBlockModel(blockState);
RandomSource randomSource = RandomSource.create();
long seed = 42L;

TextureAtlasSprite particle = blockRenderer.getBlockModelShaper().getParticleIcon(blockState);
map.put("PARTICLE", Set.of(getTextureName(particle)));
for (Direction direction : Direction.values())
map.put(direction.name(), getTexturesForFace(blockState, direction, randomSource, bakedModel, seed));
map.put("NONE", getTexturesForFace(blockState, null, randomSource, bakedModel, seed));

TextureAtlasSprite particle = blockRenderer.getBlockModelShaper().getParticleIcon(blockState);
map.put("PARTICLE", Set.of(getTextureName(particle)));
} else if (renderShape == RenderShape.ENTITYBLOCK_ANIMATED) {
map.put("PARTICLE", Set.of(getTextureName(Minecraft.getInstance().getItemRenderer().getModel(blockState.getBlock().asItem().getDefaultInstance(), WorldAPI.getCurrentWorld(), null, 42).getParticleIcon())));
}
return map;
}

Expand Down

0 comments on commit a6168d0

Please sign in to comment.