33 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.renderer;
 | |
| 
 | |
| import com.mojang.blaze3d.vertex.ByteBufferBuilder;
 | |
| import java.util.Arrays;
 | |
| import java.util.Map;
 | |
| import net.fabricmc.api.EnvType;
 | |
| import net.fabricmc.api.Environment;
 | |
| import net.minecraft.Util;
 | |
| import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class SectionBufferBuilderPack implements AutoCloseable {
 | |
| 	public static final int TOTAL_BUFFERS_SIZE = Arrays.stream(ChunkSectionLayer.values()).mapToInt(ChunkSectionLayer::bufferSize).sum();
 | |
| 	private final Map<ChunkSectionLayer, ByteBufferBuilder> buffers = Util.makeEnumMap(
 | |
| 		ChunkSectionLayer.class, chunkSectionLayer -> new ByteBufferBuilder(chunkSectionLayer.bufferSize())
 | |
| 	);
 | |
| 
 | |
| 	public ByteBufferBuilder buffer(ChunkSectionLayer layer) {
 | |
| 		return (ByteBufferBuilder)this.buffers.get(layer);
 | |
| 	}
 | |
| 
 | |
| 	public void clearAll() {
 | |
| 		this.buffers.values().forEach(ByteBufferBuilder::clear);
 | |
| 	}
 | |
| 
 | |
| 	public void discardAll() {
 | |
| 		this.buffers.values().forEach(ByteBufferBuilder::discard);
 | |
| 	}
 | |
| 
 | |
| 	public void close() {
 | |
| 		this.buffers.values().forEach(ByteBufferBuilder::close);
 | |
| 	}
 | |
| }
 |