java类net.minecraft.client.renderer.chunk.RenderChunk的实例源码

ViewFrustum.java 文件源码 项目:CustomWorldGen 阅读 23 收藏 0 点赞 0 评论 0
protected void createRenderChunks(IRenderChunkFactory renderChunkFactory)
{
    int i = this.countChunksX * this.countChunksY * this.countChunksZ;
    this.renderChunks = new RenderChunk[i];
    int j = 0;

    for (int k = 0; k < this.countChunksX; ++k)
    {
        for (int l = 0; l < this.countChunksY; ++l)
        {
            for (int i1 = 0; i1 < this.countChunksZ; ++i1)
            {
                int j1 = (i1 * this.countChunksY + l) * this.countChunksX + k;
                this.renderChunks[j1] = renderChunkFactory.create(this.world, this.renderGlobal, j++);
                this.renderChunks[j1].setPosition(k * 16, l * 16, i1 * 16);
            }
        }
    }
}
Markers.java 文件源码 项目:ForgeHax 阅读 29 收藏 0 点赞 0 评论 0
@Override
public void onBlockRenderInLoop(final RenderChunk renderChunk, final Block block, final IBlockState state, final BlockPos pos) {
    if(renderers != null) try {
        renderers.computeIfPresent(renderChunk, (chk, info) -> info.compute(() -> {
            GeometryTessellator tess = info.getTessellator();
            if (tess != null && FastReflection.Fields.BufferBuilder_isDrawing.get(tess.getBuffer(), false)) {
                BlockEntry blockEntry = options.get(state);
                if(blockEntry != null
                        && blockEntry.getReadableProperty(BoundProperty.class).isWithinBoundaries(pos.getY())) {
                    AxisAlignedBB bb = state.getSelectedBoundingBox(Helper.getWorld(), pos);
                    GeometryTessellator.drawLines(
                            tess.getBuffer(),
                            bb.minX, bb.minY, bb.minZ,
                            bb.maxX, bb.maxY, bb.maxZ,
                            GeometryMasks.Line.ALL,
                            blockEntry.getReadableProperty(ColorProperty.class).getAsBuffer()
                    );
                    info.incrementRenderCount();
                }
            }
        }));
    } catch (Exception e) {
        handleException(renderChunk, e);
    }
}
RenderList.java 文件源码 项目:CustomWorldGen 阅读 18 收藏 0 点赞 0 评论 0
public void renderChunkLayer(BlockRenderLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderchunk : this.renderChunks)
        {
            ListedRenderChunk listedrenderchunk = (ListedRenderChunk)renderchunk;
            GlStateManager.pushMatrix();
            this.preRenderChunk(renderchunk);
            GlStateManager.callList(listedrenderchunk.getDisplayList(layer, listedrenderchunk.getCompiledChunk()));
            GlStateManager.popMatrix();
        }

        GlStateManager.resetColor();
        this.renderChunks.clear();
    }
}
ViewFrustum.java 文件源码 项目:DecompiledMinecraft 阅读 17 收藏 0 点赞 0 评论 0
protected void createRenderChunks(IRenderChunkFactory renderChunkFactory)
{
    int i = this.countChunksX * this.countChunksY * this.countChunksZ;
    this.renderChunks = new RenderChunk[i];
    int j = 0;

    for (int k = 0; k < this.countChunksX; ++k)
    {
        for (int l = 0; l < this.countChunksY; ++l)
        {
            for (int i1 = 0; i1 < this.countChunksZ; ++i1)
            {
                int j1 = (i1 * this.countChunksY + l) * this.countChunksX + k;
                BlockPos blockpos = new BlockPos(k * 16, l * 16, i1 * 16);
                this.renderChunks[j1] = renderChunkFactory.makeRenderChunk(this.world, this.renderGlobal, blockpos, j++);
            }
        }
    }
}
VboRenderList.java 文件源码 项目:DecompiledMinecraft 阅读 20 收藏 0 点赞 0 评论 0
public void renderChunkLayer(EnumWorldBlockLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderchunk : this.renderChunks)
        {
            VertexBuffer vertexbuffer = renderchunk.getVertexBufferByLayer(layer.ordinal());
            GlStateManager.pushMatrix();
            this.preRenderChunk(renderchunk);
            renderchunk.multModelviewMatrix();
            vertexbuffer.bindBuffer();
            this.setupArrayPointers();
            vertexbuffer.drawArrays(7);
            GlStateManager.popMatrix();
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();
        this.renderChunks.clear();
    }
}
DynamicLight.java 文件源码 项目:BaseClient 阅读 24 收藏 0 点赞 0 评论 0
private void updateChunkLight(RenderChunk p_updateChunkLight_1_, Set<BlockPos> p_updateChunkLight_2_, Set<BlockPos> p_updateChunkLight_3_)
{
    if (p_updateChunkLight_1_ != null)
    {
        CompiledChunk compiledchunk = p_updateChunkLight_1_.getCompiledChunk();

        if (compiledchunk != null && !compiledchunk.isEmpty())
        {
            p_updateChunkLight_1_.setNeedsUpdate(true);
        }

        BlockPos blockpos = p_updateChunkLight_1_.getPosition();

        if (p_updateChunkLight_2_ != null)
        {
            p_updateChunkLight_2_.remove(blockpos);
        }

        if (p_updateChunkLight_3_ != null)
        {
            p_updateChunkLight_3_.add(blockpos);
        }
    }
}
ViewFrustum.java 文件源码 项目:BaseClient 阅读 26 收藏 0 点赞 0 评论 0
protected void createRenderChunks(IRenderChunkFactory renderChunkFactory)
{
    int i = this.countChunksX * this.countChunksY * this.countChunksZ;
    this.renderChunks = new RenderChunk[i];
    int j = 0;

    for (int k = 0; k < this.countChunksX; ++k)
    {
        for (int l = 0; l < this.countChunksY; ++l)
        {
            for (int i1 = 0; i1 < this.countChunksZ; ++i1)
            {
                int j1 = (i1 * this.countChunksY + l) * this.countChunksX + k;
                BlockPos blockpos = new BlockPos(k * 16, l * 16, i1 * 16);
                this.renderChunks[j1] = renderChunkFactory.makeRenderChunk(this.world, this.renderGlobal, blockpos, j++);
            }
        }
    }
}
VboRenderList.java 文件源码 项目:BaseClient 阅读 27 收藏 0 点赞 0 评论 0
public void renderChunkLayer(EnumWorldBlockLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderchunk : this.renderChunks)
        {
            VertexBuffer vertexbuffer = renderchunk.getVertexBufferByLayer(layer.ordinal());
            GlStateManager.pushMatrix();
            this.preRenderChunk(renderchunk);
            renderchunk.multModelviewMatrix();
            vertexbuffer.bindBuffer();
            this.setupArrayPointers();
            vertexbuffer.drawArrays(7);
            GlStateManager.popMatrix();
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();
        this.renderChunks.clear();
    }
}
VboRenderList.java 文件源码 项目:CustomWorldGen 阅读 19 收藏 0 点赞 0 评论 0
public void renderChunkLayer(BlockRenderLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderchunk : this.renderChunks)
        {
            net.minecraft.client.renderer.vertex.VertexBuffer vertexbuffer = renderchunk.getVertexBufferByLayer(layer.ordinal());
            GlStateManager.pushMatrix();
            this.preRenderChunk(renderchunk);
            renderchunk.multModelviewMatrix();
            vertexbuffer.bindBuffer();
            this.setupArrayPointers();
            vertexbuffer.drawArrays(7);
            GlStateManager.popMatrix();
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();
        this.renderChunks.clear();
    }
}
VboRenderList.java 文件源码 项目:BaseClient 阅读 31 收藏 0 点赞 0 评论 0
public void renderChunkLayer(EnumWorldBlockLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderchunk : this.renderChunks)
        {
            VertexBuffer vertexbuffer = renderchunk.getVertexBufferByLayer(layer.ordinal());
            GlStateManager.pushMatrix();
            this.preRenderChunk(renderchunk);
            renderchunk.multModelviewMatrix();
            vertexbuffer.bindBuffer();
            this.setupArrayPointers();
            vertexbuffer.drawArrays(7);
            GlStateManager.popMatrix();
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();
        this.renderChunks.clear();
    }
}
ViewFrustum.java 文件源码 项目:Backmemed 阅读 15 收藏 0 点赞 0 评论 0
protected void createRenderChunks(IRenderChunkFactory renderChunkFactory)
{
    int i = this.countChunksX * this.countChunksY * this.countChunksZ;
    this.renderChunks = new RenderChunk[i];
    int j = 0;

    for (int k = 0; k < this.countChunksX; ++k)
    {
        for (int l = 0; l < this.countChunksY; ++l)
        {
            for (int i1 = 0; i1 < this.countChunksZ; ++i1)
            {
                int j1 = (i1 * this.countChunksY + l) * this.countChunksX + k;
                this.renderChunks[j1] = renderChunkFactory.create(this.world, this.renderGlobal, j++);
                this.renderChunks[j1].setPosition(k * 16, l * 16, i1 * 16);
            }
        }
    }
}
ViewFrustum.java 文件源码 项目:Backmemed 阅读 21 收藏 0 点赞 0 评论 0
public void updateChunkPositions(double viewEntityX, double viewEntityZ)
{
    int i = MathHelper.floor(viewEntityX) - 8;
    int j = MathHelper.floor(viewEntityZ) - 8;
    int k = this.countChunksX * 16;

    for (int l = 0; l < this.countChunksX; ++l)
    {
        int i1 = this.getBaseCoordinate(i, k, l);

        for (int j1 = 0; j1 < this.countChunksZ; ++j1)
        {
            int k1 = this.getBaseCoordinate(j, k, j1);

            for (int l1 = 0; l1 < this.countChunksY; ++l1)
            {
                int i2 = l1 * 16;
                RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
                renderchunk.setPosition(i1, i2, k1);
            }
        }
    }
}
RenderGlobal.java 文件源码 项目:Backmemed 阅读 22 收藏 0 点赞 0 评论 0
private RenderGlobal.ContainerLocalRenderInformation allocateRenderInformation(RenderChunk p_allocateRenderInformation_1_, EnumFacing p_allocateRenderInformation_2_, int p_allocateRenderInformation_3_)
{
    RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation;

    if (renderInfoCache.isEmpty())
    {
        renderglobal$containerlocalrenderinformation = new RenderGlobal.ContainerLocalRenderInformation(p_allocateRenderInformation_1_, p_allocateRenderInformation_2_, p_allocateRenderInformation_3_);
    }
    else
    {
        renderglobal$containerlocalrenderinformation = (RenderGlobal.ContainerLocalRenderInformation)renderInfoCache.pollLast();
        renderglobal$containerlocalrenderinformation.initialize(p_allocateRenderInformation_1_, p_allocateRenderInformation_2_, p_allocateRenderInformation_3_);
    }

    renderglobal$containerlocalrenderinformation.cacheable = true;
    return renderglobal$containerlocalrenderinformation;
}
VboRenderList.java 文件源码 项目:Backmemed 阅读 23 收藏 0 点赞 0 评论 0
public void renderChunkLayer(BlockRenderLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderchunk : this.renderChunks)
        {
            net.minecraft.client.renderer.vertex.VertexBuffer vertexbuffer = renderchunk.getVertexBufferByLayer(layer.ordinal());
            GlStateManager.pushMatrix();
            this.preRenderChunk(renderchunk);
            renderchunk.multModelviewMatrix();
            vertexbuffer.bindBuffer();
            this.setupArrayPointers();
            vertexbuffer.drawArrays(7);
            GlStateManager.popMatrix();
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();
        this.renderChunks.clear();
    }
}
ViewFrustum.java 文件源码 项目:CustomWorldGen 阅读 21 收藏 0 点赞 0 评论 0
public void updateChunkPositions(double viewEntityX, double viewEntityZ)
{
    int i = MathHelper.floor_double(viewEntityX) - 8;
    int j = MathHelper.floor_double(viewEntityZ) - 8;
    int k = this.countChunksX * 16;

    for (int l = 0; l < this.countChunksX; ++l)
    {
        int i1 = this.getBaseCoordinate(i, k, l);

        for (int j1 = 0; j1 < this.countChunksZ; ++j1)
        {
            int k1 = this.getBaseCoordinate(j, k, j1);

            for (int l1 = 0; l1 < this.countChunksY; ++l1)
            {
                int i2 = l1 * 16;
                RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
                renderchunk.setPosition(i1, i2, k1);
            }
        }
    }
}
DynamicLight.java 文件源码 项目:Backmemed 阅读 25 收藏 0 点赞 0 评论 0
private void updateChunkLight(RenderChunk p_updateChunkLight_1_, Set<BlockPos> p_updateChunkLight_2_, Set<BlockPos> p_updateChunkLight_3_)
{
    if (p_updateChunkLight_1_ != null)
    {
        CompiledChunk compiledchunk = p_updateChunkLight_1_.getCompiledChunk();

        if (compiledchunk != null && !compiledchunk.isEmpty())
        {
            p_updateChunkLight_1_.setNeedsUpdate(false);
        }

        BlockPos blockpos = p_updateChunkLight_1_.getPosition().toImmutable();

        if (p_updateChunkLight_2_ != null)
        {
            p_updateChunkLight_2_.remove(blockpos);
        }

        if (p_updateChunkLight_3_ != null)
        {
            p_updateChunkLight_3_.add(blockpos);
        }
    }
}
RenderGlobal.java 文件源码 项目:CustomWorldGen 阅读 17 收藏 0 点赞 0 评论 0
public void updateChunks(long finishTimeNano)
{
    this.displayListEntitiesDirty |= this.renderDispatcher.runChunkUploads(finishTimeNano);

    if (!this.chunksToUpdate.isEmpty())
    {
        Iterator<RenderChunk> iterator = this.chunksToUpdate.iterator();

        while (iterator.hasNext())
        {
            RenderChunk renderchunk = (RenderChunk)iterator.next();
            boolean flag;

            if (renderchunk.isNeedsUpdateCustom())
            {
                flag = this.renderDispatcher.updateChunkNow(renderchunk);
            }
            else
            {
                flag = this.renderDispatcher.updateChunkLater(renderchunk);
            }

            if (!flag)
            {
                break;
            }

            renderchunk.clearNeedsUpdate();
            iterator.remove();
            long i = finishTimeNano - System.nanoTime();

            if (i < 0L)
            {
                break;
            }
        }
    }
}
Markers.java 文件源码 项目:ForgeHax 阅读 30 收藏 0 点赞 0 评论 0
@SubscribeEvent
public void onLoadRenderers(LoadRenderersEvent event) {
    try {
        setRenderers(new Renderers());
        setCache(new TesselatorCache(VERTEX_BUFFER_COUNT, VERTEX_BUFFER_SIZE));
        // allocate all space needed
        for (RenderChunk renderChunk : event.getViewFrustum().renderChunks) {
            renderers.register(renderChunk);
        }
    } catch (Exception e) {
        handleException(null, e);
    }
}
ViewFrustum.java 文件源码 项目:DecompiledMinecraft 阅读 29 收藏 0 点赞 0 评论 0
public void deleteGlResources()
{
    for (RenderChunk renderchunk : this.renderChunks)
    {
        renderchunk.deleteGlResources();
    }
}
ViewFrustum.java 文件源码 项目:DecompiledMinecraft 阅读 28 收藏 0 点赞 0 评论 0
public void updateChunkPositions(double viewEntityX, double viewEntityZ)
{
    int i = MathHelper.floor_double(viewEntityX) - 8;
    int j = MathHelper.floor_double(viewEntityZ) - 8;
    int k = this.countChunksX * 16;

    for (int l = 0; l < this.countChunksX; ++l)
    {
        int i1 = this.func_178157_a(i, k, l);

        for (int j1 = 0; j1 < this.countChunksZ; ++j1)
        {
            int k1 = this.func_178157_a(j, k, j1);

            for (int l1 = 0; l1 < this.countChunksY; ++l1)
            {
                int i2 = l1 * 16;
                RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
                BlockPos blockpos = new BlockPos(i1, i2, k1);

                if (!blockpos.equals(renderchunk.getPosition()))
                {
                    renderchunk.setPosition(blockpos);
                }
            }
        }
    }
}
ViewFrustum.java 文件源码 项目:DecompiledMinecraft 阅读 23 收藏 0 点赞 0 评论 0
protected RenderChunk getRenderChunk(BlockPos pos)
{
    int i = MathHelper.bucketInt(pos.getX(), 16);
    int j = MathHelper.bucketInt(pos.getY(), 16);
    int k = MathHelper.bucketInt(pos.getZ(), 16);

    if (j >= 0 && j < this.countChunksY)
    {
        i = i % this.countChunksX;

        if (i < 0)
        {
            i += this.countChunksX;
        }

        k = k % this.countChunksZ;

        if (k < 0)
        {
            k += this.countChunksZ;
        }

        int l = (k * this.countChunksY + j) * this.countChunksX + i;
        return this.renderChunks[l];
    }
    else
    {
        return null;
    }
}
RenderGlobal.java 文件源码 项目:DecompiledMinecraft 阅读 22 收藏 0 点赞 0 评论 0
public void updateChunks(long finishTimeNano)
{
    this.displayListEntitiesDirty |= this.renderDispatcher.runChunkUploads(finishTimeNano);

    if (!this.chunksToUpdate.isEmpty())
    {
        Iterator<RenderChunk> iterator = this.chunksToUpdate.iterator();

        while (iterator.hasNext())
        {
            RenderChunk renderchunk = (RenderChunk)iterator.next();

            if (!this.renderDispatcher.updateChunkLater(renderchunk))
            {
                break;
            }

            renderchunk.setNeedsUpdate(false);
            iterator.remove();
            long i = finishTimeNano - System.nanoTime();

            if (i < 0L)
            {
                break;
            }
        }
    }
}
ViewFrustum.java 文件源码 项目:CustomWorldGen 阅读 16 收藏 0 点赞 0 评论 0
public void deleteGlResources()
{
    for (RenderChunk renderchunk : this.renderChunks)
    {
        renderchunk.deleteGlResources();
    }
}
DynamicLight.java 文件源码 项目:BaseClient 阅读 22 收藏 0 点赞 0 评论 0
public void updateLitChunks(RenderGlobal p_updateLitChunks_1_)
{
    for (BlockPos blockpos : this.setLitChunkPos)
    {
        RenderChunk renderchunk = p_updateLitChunks_1_.getRenderChunk(blockpos);
        this.updateChunkLight(renderchunk, (Set<BlockPos>)null, (Set<BlockPos>)null);
    }
}
RenderList.java 文件源码 项目:BaseClient 阅读 17 收藏 0 点赞 0 评论 0
public void renderChunkLayer(EnumWorldBlockLayer layer)
{
    if (this.initialized)
    {
        if (this.renderChunks.size() == 0)
        {
            return;
        }

        for (RenderChunk renderchunk : this.renderChunks)
        {
            ListedRenderChunk listedrenderchunk = (ListedRenderChunk)renderchunk;
            GlStateManager.pushMatrix();
            this.preRenderChunk(renderchunk);
            GL11.glCallList(listedrenderchunk.getDisplayList(layer, listedrenderchunk.getCompiledChunk()));
            GlStateManager.popMatrix();
        }

        if (Config.isMultiTexture())
        {
            GlStateManager.bindCurrentTexture();
        }

        GlStateManager.resetColor();
        this.renderChunks.clear();
    }
}
ViewFrustum.java 文件源码 项目:BaseClient 阅读 15 收藏 0 点赞 0 评论 0
public void deleteGlResources()
{
    for (RenderChunk renderchunk : this.renderChunks)
    {
        renderchunk.deleteGlResources();
    }
}
ViewFrustum.java 文件源码 项目:BaseClient 阅读 24 收藏 0 点赞 0 评论 0
public void updateChunkPositions(double viewEntityX, double viewEntityZ)
{
    int i = MathHelper.floor_double(viewEntityX) - 8;
    int j = MathHelper.floor_double(viewEntityZ) - 8;
    int k = this.countChunksX * 16;

    for (int l = 0; l < this.countChunksX; ++l)
    {
        int i1 = this.func_178157_a(i, k, l);

        for (int j1 = 0; j1 < this.countChunksZ; ++j1)
        {
            int k1 = this.func_178157_a(j, k, j1);

            for (int l1 = 0; l1 < this.countChunksY; ++l1)
            {
                int i2 = l1 * 16;
                RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
                BlockPos blockpos = renderchunk.getPosition();

                if (blockpos.getX() != i1 || blockpos.getY() != i2 || blockpos.getZ() != k1)
                {
                    BlockPos blockpos1 = new BlockPos(i1, i2, k1);

                    if (!blockpos1.equals(renderchunk.getPosition()))
                    {
                        renderchunk.setPosition(blockpos1);
                    }
                }
            }
        }
    }
}
ViewFrustum.java 文件源码 项目:BaseClient 阅读 15 收藏 0 点赞 0 评论 0
protected RenderChunk getRenderChunk(BlockPos pos)
{
    int i = MathHelper.bucketInt(pos.getX(), 16);
    int j = MathHelper.bucketInt(pos.getY(), 16);
    int k = MathHelper.bucketInt(pos.getZ(), 16);

    if (j >= 0 && j < this.countChunksY)
    {
        i = i % this.countChunksX;

        if (i < 0)
        {
            i += this.countChunksX;
        }

        k = k % this.countChunksZ;

        if (k < 0)
        {
            k += this.countChunksZ;
        }

        int l = (k * this.countChunksY + j) * this.countChunksX + i;
        return this.renderChunks[l];
    }
    else
    {
        return null;
    }
}
RenderGlobal.java 文件源码 项目:BaseClient 阅读 20 收藏 0 点赞 0 评论 0
private RenderChunk func_181562_a(BlockPos p_181562_1_, RenderChunk p_181562_2_, EnumFacing p_181562_3_)
{
    BlockPos blockpos = p_181562_2_.getPositionOffset16(p_181562_3_);

    if (blockpos.getY() >= 0 && blockpos.getY() < 256)
    {
        int i = MathHelper.abs_int(p_181562_1_.getX() - blockpos.getX());
        int j = MathHelper.abs_int(p_181562_1_.getZ() - blockpos.getZ());

        if (Config.isFogOff())
        {
            if (i > this.renderDistance || j > this.renderDistance)
            {
                return null;
            }
        }
        else
        {
            int k = i * i + j * j;

            if (k > this.renderDistanceSq)
            {
                return null;
            }
        }

        return this.viewFrustum.getRenderChunk(blockpos);
    }
    else
    {
        return null;
    }
}
RenderGlobal.java 文件源码 项目:BaseClient 阅读 22 收藏 0 点赞 0 评论 0
public RenderChunk getRenderChunk(RenderChunk p_getRenderChunk_1_, EnumFacing p_getRenderChunk_2_)
{
    if (p_getRenderChunk_1_ == null)
    {
        return null;
    }
    else
    {
        BlockPos blockpos = p_getRenderChunk_1_.func_181701_a(p_getRenderChunk_2_);
        return this.viewFrustum.getRenderChunk(blockpos);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号