Example usage for net.minecraftforge.client MinecraftForgeClient getRegionRenderCache

List of usage examples for net.minecraftforge.client MinecraftForgeClient getRegionRenderCache

Introduction

In this page you can find the example usage for net.minecraftforge.client MinecraftForgeClient getRegionRenderCache.

Prototype

public static ChunkRenderCache getRegionRenderCache(World world, BlockPos pos) 

Source Link

Usage

From source file:appeng.client.render.tesr.SkyCompassTESR.java

License:Open Source License

@Override
public void renderTileEntityFast(TileSkyCompass te, double x, double y, double z, float partialTicks,
        int destroyStage, VertexBuffer buffer) {

    if (!te.hasWorldObj()) {
        return;//from  ww w .ja  v a2s.c om
    }

    if (blockRenderer == null) {
        blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    }

    BlockPos pos = te.getPos();
    IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
    IBlockState state = world.getBlockState(pos);
    if (state.getPropertyNames().contains(Properties.StaticProperty)) {
        state = state.withProperty(Properties.StaticProperty, false);
    }

    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState exState = (IExtendedBlockState) state.getBlock().getExtendedState(state, world,
                pos);

        IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
        exState = exState.withProperty(BlockSkyCompass.ROTATION, getRotation(te));

        // Flip forward/up for rendering, the base model is facing up without any rotation
        EnumFacing forward = exState.getValue(AEBaseTileBlock.FORWARD);
        EnumFacing up = exState.getValue(AEBaseTileBlock.UP);
        // This ensures the needle isn't flipped by the model rotator. Since the model is symmetrical, this should not affect the appearance
        if (forward == EnumFacing.UP || forward == EnumFacing.DOWN) {
            up = EnumFacing.NORTH;
        }
        exState = exState.withProperty(AEBaseTileBlock.FORWARD, up).withProperty(AEBaseTileBlock.UP, forward);

        buffer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());

        blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, buffer, false);
    }
}

From source file:vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube.java

License:Open Source License

private void renderAnimatedModel(TileCorporeaCrystalCube te, double x, double y, double z, float partialTick) {
    // From FastTESR.renderTileEntityAt
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer worldRenderer = tessellator.getBuffer();
    bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();/*from  w w  w.  ja v a  2  s .co m*/
    GlStateManager.disableCull();

    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    } else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }

    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

    // Inlined AnimationTESR.renderTileEntityFast
    if (!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) {
        return;
    }
    if (blockRenderer == null)
        blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos pos = te.getPos();
    IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
    IBlockState state = world.getBlockState(pos);
    if (state.getPropertyNames().contains(Properties.StaticProperty)) {
        state = state.withProperty(Properties.StaticProperty, false);
    }
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState exState = (IExtendedBlockState) state;
        if (exState.getUnlistedNames().contains(Properties.AnimationProperty)) {
            float time = Animation.getWorldTime(getWorld(), partialTick);
            Pair<IModelState, Iterable<Event>> pair = te
                    .getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
            // handleEvents(te, time, pair.getRight());

            IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
            exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());

            worldRenderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());

            blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, worldRenderer, false);
        }
    }
    // End inline AnimationTESR.renderTileEntityFast

    worldRenderer.setTranslation(0, 0, 0);

    tessellator.draw();

    RenderHelper.enableStandardItemLighting();
}