Java源码示例:net.minecraft.client.renderer.chunk.CompiledChunk
示例1
private void addTileEntity(BlockPos pos, CompiledChunk compiledChunk, Set<TileEntity> tileEntities)
{
TileEntity te = this.schematicWorldView.getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK);
if (te != null)
{
TileEntitySpecialRenderer<TileEntity> tesr = TileEntityRendererDispatcher.instance.<TileEntity>getRenderer(te);
if (tesr != null)
{
compiledChunk.addTileEntity(te);
if (tesr.isGlobalRenderer(te))
{
tileEntities.add(te);
}
}
}
}
示例2
@Override
protected int getRenderedChunks()
{
int count = 0;
for (RenderChunk renderChunk : this.renderInfos)
{
CompiledChunk compiledchunk = renderChunk.compiledChunk;
if (compiledchunk != CompiledChunk.DUMMY && compiledchunk.isEmpty() == false)
{
++count;
}
}
return count;
}
示例3
private void renderBlockOverlay(OverlayRenderType type)
{
this.world.profiler.startSection("overlay_" + type.name());
this.world.profiler.startSection("filter_empty");
for (int i = this.renderInfos.size() - 1; i >= 0; --i)
{
RenderChunkSchematicVbo renderChunk = this.renderInfos.get(i);
if (renderChunk.getChunkRenderData() != CompiledChunk.DUMMY && renderChunk.hasOverlay())
{
CompiledChunkSchematic compiledChunk = renderChunk.getChunkRenderData();
if (compiledChunk.isOverlayTypeEmpty(type) == false)
{
this.renderContainer.addOverlayChunk(renderChunk);
}
}
}
this.world.profiler.endStartSection("render");
this.renderBlockOverlayBuffers(type);
this.world.profiler.endSection();
this.world.profiler.endSection();
}
示例4
public ListenableFuture<Object> uploadChunkBlocks(final BlockRenderLayer layer, final BufferBuilder buffer,
final RenderChunkSchematicVbo renderChunk, final CompiledChunk compiledChunk, final double distanceSq)
{
if (Minecraft.getMinecraft().isCallingFromMinecraftThread())
{
//if (GuiBase.isCtrlDown()) System.out.printf("uploadChunkBlocks()\n");
if (OpenGlHelper.useVbo())
{
this.uploadVertexBuffer(buffer, renderChunk.getVertexBufferByLayer(layer.ordinal()));
}
else
{
this.uploadDisplayList(buffer, ((RenderChunkSchematicList) renderChunk).getDisplayList(layer, compiledChunk), renderChunk);
}
buffer.setTranslation(0.0D, 0.0D, 0.0D);
return Futures.<Object>immediateFuture(null);
}
else
{
ListenableFutureTask<Object> futureTask = ListenableFutureTask.<Object>create(new Runnable()
{
@Override
public void run()
{
ChunkRenderDispatcherLitematica.this.uploadChunkBlocks(layer, buffer, renderChunk, compiledChunk, distanceSq);
}
}, null);
synchronized (this.queueChunkUploads)
{
this.queueChunkUploads.add(new ChunkRenderDispatcherLitematica.PendingUpload(futureTask, distanceSq));
return futureTask;
}
}
}
示例5
/**
* @reason Adds liquid textures to the set of visible textures in the compiled chunk. Note
* that this is necessary only for liquid textures, since Forge liquids are rendered by the
* normal block rendering code.
*/
@ModifyVariable(method = "renderFluid", at = @At(value = "CONSTANT", args = "floatValue=0.001", ordinal = 1), ordinal = 0)
private TextureAtlasSprite afterTextureDetermined(TextureAtlasSprite texture) {
CompiledChunk compiledChunk = TemporaryStorage.currentCompiledChunk.get();
if (compiledChunk != null) {
((IPatchedCompiledChunk) compiledChunk).getVisibleTextures().add(texture);
} else {
// Called from non-chunk render thread. Unfortunately, the best we can do
// is assume it's only going to be used once:
((IPatchedTextureAtlasSprite) texture).markNeedsAnimationUpdate();
}
return texture;
}
示例6
public int getDisplayList(BlockRenderLayer layer, CompiledChunk compiledChunk)
{
return compiledChunk.isLayerEmpty(layer) == false ? this.baseDisplayList + layer.ordinal() : -1;
}
示例7
public int renderBlockLayer(BlockRenderLayer blockLayerIn, double partialTicks, Entity entityIn)
{
this.world.profiler.startSection("render_block_layer_" + blockLayerIn);
RenderUtils.disableItemLighting();
if (blockLayerIn == BlockRenderLayer.TRANSLUCENT)
{
this.world.profiler.startSection("translucent_sort");
double diffX = entityIn.posX - this.prevRenderSortX;
double diffY = entityIn.posY - this.prevRenderSortY;
double diffZ = entityIn.posZ - this.prevRenderSortZ;
if (diffX * diffX + diffY * diffY + diffZ * diffZ > 1.0D)
{
this.prevRenderSortX = entityIn.posX;
this.prevRenderSortY = entityIn.posY;
this.prevRenderSortZ = entityIn.posZ;
int i = 0;
for (RenderChunkSchematicVbo renderChunk : this.renderInfos)
{
if ((renderChunk.getChunkRenderData().isLayerStarted(blockLayerIn) ||
(renderChunk.getChunkRenderData() != CompiledChunk.DUMMY && renderChunk.hasOverlay())) && i++ < 15)
{
this.renderDispatcher.updateTransparencyLater(renderChunk);
}
}
}
this.world.profiler.endSection();
}
this.world.profiler.startSection("filter_empty");
boolean reverse = blockLayerIn == BlockRenderLayer.TRANSLUCENT;
int startIndex = reverse ? this.renderInfos.size() - 1 : 0;
int stopIndex = reverse ? -1 : this.renderInfos.size();
int increment = reverse ? -1 : 1;
int count = 0;
for (int i = startIndex; i != stopIndex; i += increment)
{
RenderChunkSchematicVbo renderchunk = this.renderInfos.get(i);
if (renderchunk.getChunkRenderData().isLayerEmpty(blockLayerIn) == false)
{
++count;
this.renderContainer.addRenderChunk(renderchunk, blockLayerIn);
}
}
this.world.profiler.endStartSection("render");
this.renderBlockLayer(blockLayerIn);
this.world.profiler.endSection();
this.world.profiler.endSection();
return count;
}
示例8
public CompiledChunk getCompiledChunk()
{
return this.compiledChunk;
}
示例9
public void setCompiledChunk(CompiledChunk compiledChunkIn)
{
this.compiledChunk = compiledChunkIn;
}
示例10
/**
* @reason Store the chunk currently being rebuild in TemporaryStorage.currentCompiledChunk
* by thread ID (there are multiple chunk renderer threads working at once).
*/
@Inject(method = "rebuildChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/chunk/CompiledChunk;<init>()V", ordinal = 0, shift = At.Shift.BY, by = 2), locals = LocalCapture.CAPTURE_FAILHARD)
private void onRebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator generator, CallbackInfo ci, CompiledChunk compiledChunk) {
TemporaryStorage.currentCompiledChunk.set(compiledChunk);
}
示例11
public static boolean isDummy(RenderChunk chunk) {
return chunk != null && chunk.getCompiledChunk() == CompiledChunk.DUMMY;
}