Java Code Examples for net.minecraft.block.state.IBlockState#getRenderType()

The following examples show how to use net.minecraft.block.state.IBlockState#getRenderType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityBlockRenderer.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public void doRender(EntityBlock entity, double x, double y, double z, float yaw, float partialTicks) {
	final IBlockState blockState = entity.getBlockState();

	if (blockState.getRenderType() != EnumBlockRenderType.INVISIBLE) {
		GlStateManager.pushMatrix();
		GlStateManager.translate(x - 0.5, y, z + 0.5);
		GlStateManager.disableLighting();

		bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

		Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(blockState, entity.getBrightness());

		GlStateManager.enableLighting();
		GlStateManager.popMatrix();
		super.doRender(entity, x, y, z, yaw, partialTicks);
	}
}
 
Example 2
Source File: RenderFallTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityFallTofu entity, double x, double y, double z, float entityYaw, float partialTicks) {

    IBlockState iblockstate = BlockLoader.tofuTerrain.getDefaultState();

    if (iblockstate.getRenderType() == EnumBlockRenderType.MODEL) {
        World world = entity.getWorldObj();

        if (iblockstate != world.getBlockState(new BlockPos(entity)) && iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();

            if (this.renderOutlines) {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            bufferbuilder.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float) (x - (double) blockpos.getX() - 0.5D), (float) (y - (double) blockpos.getY()), (float) (z - (double) blockpos.getZ() - 0.5D));
            BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(iblockstate), iblockstate, blockpos, bufferbuilder, false);
            tessellator.draw();

            if (this.renderOutlines) {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }

}
 
Example 3
Source File: FacadeHelper.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static boolean isValidFacade(ItemStack itemStack) {
    IBlockState rawBlockState = lookupBlockForItemUnsafe(itemStack);
    return rawBlockState != null &&
        !rawBlockState.getBlock().hasTileEntity(rawBlockState) &&
        !rawBlockState.getBlock().hasTileEntity() &&
        rawBlockState.getRenderType() == EnumBlockRenderType.MODEL &&
        rawBlockState.isFullCube();
}
 
Example 4
Source File: RenderGlobalSchematic.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean renderBlock(IBlockState state, BlockPos pos, IBlockAccess blockAccess, BufferBuilder bufferBuilderIn)
{
    try
    {
        EnumBlockRenderType renderType = state.getRenderType();

        if (renderType == EnumBlockRenderType.INVISIBLE)
        {
            return false;
        }
        else
        {
            switch (renderType)
            {
                case MODEL:
                    return this.blockModelRenderer.renderModel(blockAccess, this.getModelForState(state), state, pos, bufferBuilderIn);
                case ENTITYBLOCK_ANIMATED:
                    return false;
                case LIQUID:
                    return this.fluidRenderer.renderFluid(blockAccess, state, pos, bufferBuilderIn);
                default:
                    return false;
            }
        }
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Tesselating block in world");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being tesselated");
        CrashReportCategory.addBlockInfo(crashreportcategory, pos, state.getBlock(), state.getBlock().getMetaFromState(state));
        throw new ReportedException(crashreport);
    }
}
 
Example 5
Source File: RenderChunkSchematicVbo.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void renderBlocksAndOverlay(BlockPos pos, Set<TileEntity> tileEntities, boolean[] usedLayers, CompiledChunkSchematic data, BufferBuilderCache buffers)
{
    IBlockState stateSchematic = this.schematicWorldView.getBlockState(pos);
    IBlockState stateClient    = this.clientWorldView.getBlockState(pos);
    stateSchematic = stateSchematic.getActualState(this.schematicWorldView, pos);
    stateClient = stateClient.getActualState(this.clientWorldView, pos);
    Block blockSchematic = stateSchematic.getBlock();
    Block blockClient = stateClient.getBlock();
    boolean clientHasAir = blockClient == Blocks.AIR;
    boolean schematicHasAir = blockSchematic == Blocks.AIR;

    if (clientHasAir && schematicHasAir)
    {
        return;
    }

    // Schematic has a block, client has air
    if (clientHasAir || (stateSchematic != stateClient && this.renderColliding))
    {
        if (blockSchematic.hasTileEntity())
        {
            this.addTileEntity(pos, data, tileEntities);
        }

        BlockRenderLayer layer = this.renderAsTranslucent ? BlockRenderLayer.TRANSLUCENT : blockSchematic.getRenderLayer();
        int layerIndex = layer.ordinal();

        if (stateSchematic.getRenderType() != EnumBlockRenderType.INVISIBLE)
        {
            BufferBuilder bufferSchematic = buffers.getWorldRendererByLayerId(layerIndex);

            if (data.isLayerStarted(layer) == false)
            {
                data.setLayerStarted(layer);
                this.preRenderBlocks(bufferSchematic, this.getPosition());
            }

            usedLayers[layerIndex] |= this.renderGlobal.renderBlock(stateSchematic, pos, this.schematicWorldView, bufferSchematic);
        }
    }

    if (this.overlayEnabled)
    {
        OverlayType type = this.getOverlayType(stateSchematic, stateClient);
        Color4f overlayColor = this.getOverlayColor(type);

        if (overlayColor != null)
        {
            this.renderOverlay(pos, stateSchematic, type, overlayColor, data, buffers);
        }
    }
}
 
Example 6
Source File: RenderFallingBlockEU.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void doRender(EntityFallingBlockEU entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    IBlockState state = entity.getBlockState();

    if (state != null && state.getRenderType() == EnumBlockRenderType.MODEL)
    {
        World world = entity.getEntityWorld();

        if (state != world.getBlockState(new BlockPos(entity)) && state.getRenderType() != EnumBlockRenderType.INVISIBLE)
        {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder buffer = tessellator.getBuffer();

            if (this.renderOutlines)
            {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            buffer.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos pos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float)(x - pos.getX() - 0.5D), (float)(y - pos.getY()), (float)(z - pos.getZ() - 0.5D));
            BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            dispatcher.getBlockModelRenderer().renderModel(
                world, dispatcher.getModelForState(state), state, pos, buffer, false, MathHelper.getPositionRandom(entity.getOrigin()));
            tessellator.draw();

            if (this.renderOutlines)
            {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();

            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }
}