Search in sources :

Example 1 with FakeEntity

use of com.minecolonies.structures.fake.FakeEntity in project minecolonies by Minecolonies.

the class Structure method renderGhost.

public void renderGhost(final World world, final ModelHolder holder, final EntityPlayer player, final float partialTicks) {
    final boolean existingModel = !this.mc.world.isAirBlock(holder.pos);
    final IBlockState actualState = holder.actualState;
    final Block block = actualState.getBlock();
    if (actualState.getRenderType() == EnumBlockRenderType.MODEL) {
        final BlockRenderLayer originalLayer = MinecraftForgeClient.getRenderLayer();
        for (final BlockRenderLayer layer : BlockRenderLayer.values()) {
            if (block.canRenderInLayer(actualState, layer)) {
                this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
                ForgeHooksClient.setRenderLayer(layer);
                this.renderGhostBlock(world, holder, player, layer, existingModel, partialTicks);
                holder.setRendered(true);
            }
        }
        ForgeHooksClient.setRenderLayer(originalLayer);
    }
    if (holder.te != null && !holder.isRendered()) {
        final TileEntity te = holder.te;
        te.setPos(holder.pos);
        final FakeWorld fakeWorld = new FakeWorld(holder.actualState, world.getSaveHandler(), world.getWorldInfo(), world.provider, world.theProfiler, true);
        te.setWorld(fakeWorld);
        final int pass = 0;
        if (te.shouldRenderInPass(pass)) {
            final TileEntityRendererDispatcher terd = TileEntityRendererDispatcher.instance;
            terd.prepare(fakeWorld, Minecraft.getMinecraft().renderEngine, Minecraft.getMinecraft().fontRendererObj, new FakeEntity(fakeWorld), null, 0.0F);
            GL11.glPushMatrix();
            terd.renderEngine = Minecraft.getMinecraft().renderEngine;
            terd.preDrawBatch();
            GL11.glColor4f(1F, 1F, 1F, 1F);
            terd.renderTileEntity(te, partialTicks, -1);
            terd.drawBatch(pass);
            GL11.glPopMatrix();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FakeEntity(com.minecolonies.structures.fake.FakeEntity) IBlockState(net.minecraft.block.state.IBlockState) FakeWorld(com.minecolonies.structures.fake.FakeWorld) Block(net.minecraft.block.Block) TileEntityRendererDispatcher(net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher)

Aggregations

FakeEntity (com.minecolonies.structures.fake.FakeEntity)1 FakeWorld (com.minecolonies.structures.fake.FakeWorld)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 TileEntityRendererDispatcher (net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher)1 TileEntity (net.minecraft.tileentity.TileEntity)1