use of net.minecraft.client.renderer.chunk.VisGraph in project Minecraft-SlientClient-Hack by YouNeverKnow00.
the class RenderGlobal method getVisibleFacings.
private Set<EnumFacing> getVisibleFacings(BlockPos pos) {
VisGraph visgraph = new VisGraph();
BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
Chunk chunk = this.theWorld.getChunkFromBlockCoords(blockpos);
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos.add(15, 15, 15))) {
if (chunk.getBlockState(blockpos$mutableblockpos).isOpaqueCube()) {
visgraph.setOpaqueCube(blockpos$mutableblockpos);
}
}
return visgraph.getVisibleFacings(pos);
}
use of net.minecraft.client.renderer.chunk.VisGraph in project Spark-Client by Spark-Client-Development.
the class RenderOverlay method rebuildChunk.
@Override
public void rebuildChunk(final float x, final float y, final float z, final ChunkCompileTaskGenerator generator) {
final CompiledOverlay compiledOverlay = new CompiledOverlay();
final BlockPos from = getPosition();
final BlockPos to = from.add(15, 15, 15);
final BlockPos fromEx = from.add(-1, -1, -1);
final BlockPos toEx = to.add(1, 1, 1);
generator.getLock().lock();
ChunkCache chunkCache;
final SchematicWorld schematic = (SchematicWorld) this.world;
try {
if (generator.getStatus() != ChunkCompileTaskGenerator.Status.COMPILING) {
return;
}
if (from.getX() < 0 || from.getZ() < 0 || from.getX() >= schematic.getWidth() || from.getZ() >= schematic.getLength()) {
generator.setCompiledChunk(CompiledChunk.DUMMY);
return;
}
chunkCache = new ChunkCache(this.world, fromEx, toEx, 1);
generator.setCompiledChunk(compiledOverlay);
} finally {
generator.getLock().unlock();
}
final VisGraph visgraph = new VisGraph();
if (!chunkCache.isEmpty()) {
++renderChunksUpdated;
final World mcWorld = Minecraft.getMinecraft().world;
final BlockRenderLayer layer = BlockRenderLayer.TRANSLUCENT;
final BufferBuilder buffer = generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(layer);
GeometryTessellator.setStaticDelta(0.005);
// Elements in this array may be null, indicating that nothing should be rendered (or out of bounds)
// 18 elements to provide padding on both sides (this padding is not rendered).
final BlockType[][][] types = new BlockType[18][18][18];
// Build the type array (including the padding)
BlockPos.MutableBlockPos mcPos = new BlockPos.MutableBlockPos();
for (final BlockPos.MutableBlockPos pos : BlockPos.getAllInBoxMutable(fromEx, toEx)) {
if (!schematic.isInside(pos) || !schematic.layerMode.shouldUseLayer(schematic, pos.getY())) {
continue;
}
// Indices in types
int secX = pos.getX() - fromEx.getX();
int secY = pos.getY() - fromEx.getY();
int secZ = pos.getZ() - fromEx.getZ();
final IBlockState schBlockState = schematic.getBlockState(pos);
final Block schBlock = schBlockState.getBlock();
if (schBlockState.isOpaqueCube()) {
visgraph.setOpaqueCube(pos);
}
mcPos.setPos(pos.getX() + schematic.position.getX(), pos.getY() + schematic.position.getY(), pos.getZ() + schematic.position.getZ());
final IBlockState mcBlockState = mcWorld.getBlockState(mcPos);
final Block mcBlock = mcBlockState.getBlock();
final boolean isSchAirBlock = schematic.isAirBlock(pos);
final boolean isMcAirBlock = mcWorld.isAirBlock(mcPos) || SchematicaConfig.INSTANCE.extraAirBlocks.isValueSelected(mcBlock);
if (SchematicaConfig.INSTANCE.highlightAir.getValue() && !isMcAirBlock && isSchAirBlock) {
types[secX][secY][secZ] = BlockType.EXTRA_BLOCK;
} else if (SchematicaConfig.INSTANCE.highlight.getValue()) {
if (!isMcAirBlock && !isSchAirBlock) {
if (schBlock != mcBlock) {
types[secX][secY][secZ] = BlockType.WRONG_BLOCK;
} else if (schBlock.getMetaFromState(schBlockState) != mcBlock.getMetaFromState(mcBlockState)) {
types[secX][secY][secZ] = BlockType.WRONG_META;
}
} else if (!isSchAirBlock) {
types[secX][secY][secZ] = BlockType.MISSING_BLOCK;
}
}
}
// Draw the type array (but not the padding)
for (final BlockPos.MutableBlockPos pos : BlockPos.getAllInBoxMutable(from, to)) {
int secX = pos.getX() - fromEx.getX();
int secY = pos.getY() - fromEx.getY();
int secZ = pos.getZ() - fromEx.getZ();
BlockType type = types[secX][secY][secZ];
if (type != null) {
if (!compiledOverlay.isLayerStarted(layer)) {
compiledOverlay.setLayerStarted(layer);
preRenderBlocks(buffer, from);
}
int sides = getSides(types, secX, secY, secZ);
GeometryTessellator.drawCuboid(buffer, pos, sides, 0x3F000000 | type.color);
compiledOverlay.setLayerUsed(layer);
}
}
if (compiledOverlay.isLayerStarted(layer)) {
postRenderBlocks(layer, x, y, z, buffer, compiledOverlay);
}
}
compiledOverlay.setVisibility(visgraph.computeVisibility());
}
use of net.minecraft.client.renderer.chunk.VisGraph in project kull by Sxmurai.
the class RenderGlobal method getVisibleFacings.
private Set<EnumFacing> getVisibleFacings(BlockPos pos) {
VisGraph visgraph = new VisGraph();
BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
Chunk chunk = this.theWorld.getChunkFromBlockCoords(blockpos);
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos.add(15, 15, 15))) {
if (chunk.getBlock(blockpos$mutableblockpos).isOpaqueCube()) {
visgraph.func_178606_a(blockpos$mutableblockpos);
}
}
return visgraph.func_178609_b(pos);
}
use of net.minecraft.client.renderer.chunk.VisGraph in project Spark-Client by Spark-Client-Development.
the class RenderSchematic method getVisibleSides.
private Set<EnumFacing> getVisibleSides(final BlockPos pos) {
final VisGraph visgraph = new VisGraph();
final BlockPos posChunk = new BlockPos(pos.getX() & ~0xF, pos.getY() & ~0xF, pos.getZ() & ~0xF);
for (final BlockPos.MutableBlockPos mutableBlockPos : BlockPos.getAllInBoxMutable(posChunk, posChunk.add(15, 15, 15))) {
if (this.world.getBlockState(mutableBlockPos).isOpaqueCube()) {
visgraph.setOpaqueCube(mutableBlockPos);
}
}
return visgraph.getVisibleFacings(pos);
}
use of net.minecraft.client.renderer.chunk.VisGraph in project Zone by wje5.
the class ChunkWrapper method rebuildChunk.
public void rebuildChunk(float x, float y, float z, ChunkRenderTaskWrapper wrapper) {
CompiledChunk compiledchunk = new CompiledChunk();
wrapper.getLock().lock();
try {
if (wrapper.getStatus() != ChunkCompileTaskGenerator.Status.COMPILING) {
return;
}
wrapper.setCompiledChunk(compiledchunk);
} finally {
wrapper.getLock().unlock();
}
VisGraph graph = new VisGraph();
Set<TileEntity> set = new HashSet<TileEntity>();
if (!chunkCache.isEmpty()) {
updatedCount++;
boolean[] usedLayers = new boolean[BlockRenderLayer.values().length];
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
for (BlockPos.MutableBlockPos pos : BlockPos.getAllInBoxMutable(position, position.add(15, 15, 15))) {
IBlockState state = chunkCache.getBlockState(pos);
Block block = state.getBlock();
if (state.isOpaqueCube()) {
graph.setOpaqueCube(pos);
}
if (block.hasTileEntity(state)) {
TileEntity tileentity = chunkCache.getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK);
if (tileentity != null) {
TileEntitySpecialRenderer<TileEntity> tesr = TileEntityRendererDispatcher.instance.<TileEntity>getRenderer(tileentity);
if (tesr != null) {
if (tesr.isGlobalRenderer(tileentity)) {
set.add(tileentity);
} else {
compiledchunk.addTileEntity(tileentity);
}
}
}
}
for (BlockRenderLayer layer : BlockRenderLayer.values()) {
if (!block.canRenderInLayer(state, layer)) {
continue;
}
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(layer);
int j = layer.ordinal();
if (block.getDefaultState().getRenderType() != EnumBlockRenderType.INVISIBLE) {
BufferBuilder bufferbuilder = wrapper.getCacheBuilder().getWorldRendererByLayerId(j);
if (!compiledchunk.isLayerStarted(layer)) {
compiledchunk.setLayerStarted(layer);
preRender(bufferbuilder, position);
}
usedLayers[j] |= dispatcher.renderBlock(state, pos, chunkCache, bufferbuilder);
}
}
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
}
for (BlockRenderLayer blockrenderlayer : BlockRenderLayer.values()) {
if (usedLayers[blockrenderlayer.ordinal()]) {
setLayerUsed(compiledchunk, blockrenderlayer);
}
if (compiledchunk.isLayerStarted(blockrenderlayer)) {
postRender(blockrenderlayer, x, y, z, wrapper.getCacheBuilder().getWorldRendererByLayer(blockrenderlayer), compiledchunk);
}
}
}
compiledchunk.setVisibility(graph.computeVisibility());
this.lockCompileTask.lock();
try {
Set<TileEntity> s = new HashSet<TileEntity>();
Set<TileEntity> s2 = Sets.newHashSet(tileEntities);
s.removeAll(tileEntities);
s2.removeAll(set);
tileEntities.clear();
tileEntities.addAll(set);
// renderGlobal.updateTileEntities(s2, s);TODO
} finally {
lockCompileTask.unlock();
}
}
Aggregations