Search in sources :

Example 1 with DirectionPropertyBlock

use of net.dries007.tfc.common.blocks.DirectionPropertyBlock in project TerraFirmaCraft by TerraFirmaCraft.

the class SheetPileBlockEntityRenderer method render.

@Override
public void render(SheetPileBlockEntity pile, float partialTick, PoseStack poseStack, MultiBufferSource buffer, int packedLight, int packedOverlay) {
    final BlockState state = pile.getBlockState();
    if (state.getBlock() instanceof DirectionPropertyBlock) {
        final Function<ResourceLocation, TextureAtlasSprite> textureAtlas = Minecraft.getInstance().getTextureAtlas(RenderHelpers.BLOCKS_ATLAS);
        final VertexConsumer builder = buffer.getBuffer(RenderType.cutout());
        for (Direction direction : Helpers.DIRECTIONS) {
            if (// The properties are authoritative on which sides should be rendered
            state.getValue(DirectionPropertyBlock.getProperty(direction))) {
                final Metal metal = pile.getOrCacheMetal(direction);
                final TextureAtlasSprite sprite = textureAtlas.apply(metal.getTextureId());
                renderSheet(poseStack, sprite, builder, direction, packedLight, packedOverlay);
            }
        }
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.resources.ResourceLocation) DirectionPropertyBlock(net.dries007.tfc.common.blocks.DirectionPropertyBlock) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) Metal(net.dries007.tfc.util.Metal) Direction(net.minecraft.core.Direction)

Aggregations

VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)1 DirectionPropertyBlock (net.dries007.tfc.common.blocks.DirectionPropertyBlock)1 Metal (net.dries007.tfc.util.Metal)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 Direction (net.minecraft.core.Direction)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 BlockState (net.minecraft.world.level.block.state.BlockState)1