use of com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.
the class RenderSchematic method onRenderWorldLast.
@SubscribeEvent
public void onRenderWorldLast(final RenderWorldLastEvent event) {
// /< https://github.com/Lunatrius/Schematica/pull/452
final EntityPlayerSP player = this.mc.getRenderViewEntity() instanceof EntityPlayerSP ? (EntityPlayerSP) this.mc.getRenderViewEntity() : this.mc.player;
if (player != null) {
this.profiler.startSection("schematica");
ClientProxy.setPlayerData(player, event.getPartialTicks());
final SchematicWorld schematic = ClientProxy.schematic;
final boolean isRenderingSchematic = schematic != null && schematic.isRendering;
this.profiler.startSection("schematic");
if (isRenderingSchematic) {
GlStateManager.pushMatrix();
renderSchematic(schematic, event.getPartialTicks());
GlStateManager.popMatrix();
}
this.profiler.endStartSection("guide");
if (ClientProxy.isRenderingGuide || isRenderingSchematic) {
GlStateManager.pushMatrix();
renderOverlay(schematic, isRenderingSchematic);
GlStateManager.popMatrix();
}
this.profiler.endSection();
this.profiler.endSection();
}
}
use of com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.
the class RenderTickHandler method onRenderTick.
@SubscribeEvent
public void onRenderTick(final TickEvent.RenderTickEvent event) {
final SchematicWorld schematic = ClientProxy.schematic;
ClientProxy.objectMouseOver = schematic != null ? rayTrace(schematic, 1.0f) : null;
}
use of com.github.lunatrius.schematica.client.world.SchematicWorld 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 com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.
the class SchematicRenderChunkList method rebuildChunk.
@Override
public void rebuildChunk(final float x, final float y, final float z, final ChunkCompileTaskGenerator generator) {
generator.getLock().lock();
try {
if (generator.getStatus() == ChunkCompileTaskGenerator.Status.COMPILING) {
final BlockPos from = getPosition();
final SchematicWorld schematic = (SchematicWorld) this.world;
if (from.getX() < 0 || from.getZ() < 0 || from.getX() >= schematic.getWidth() || from.getZ() >= schematic.getLength()) {
final SetVisibility visibility = new SetVisibility();
visibility.setAllVisible(true);
final CompiledChunk dummy = new CompiledChunk();
dummy.setVisibility(visibility);
generator.setCompiledChunk(dummy);
return;
}
}
} finally {
generator.getLock().unlock();
}
super.rebuildChunk(x, y, z, generator);
}
use of com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.
the class SchematicaConfig method onKeyInput.
@SubscribeEvent
public void onKeyInput(final InputEvent event) {
if (mc.currentScreen == null) {
final SchematicWorld schematic = ClientProxy.schematic;
int key = event.getKey();
if (key == LOAD.getKey())
mc.displayGuiScreen(new GuiSchematicLoad(mc.currentScreen));
if (key == CONTROL.getKey())
mc.displayGuiScreen(new GuiSchematicControl(mc.currentScreen));
if (key == LAYER_INC.getKey())
if (schematic != null && schematic.layerMode != SchematicWorld.LayerMode.ALL) {
schematic.renderingLayer = MathHelper.clamp(schematic.renderingLayer + 1, 0, schematic.getHeight() - 1);
RenderSchematic.INSTANCE.refresh();
}
if (key == LAYER_DEC.getKey())
if (schematic != null && schematic.layerMode != SchematicWorld.LayerMode.ALL) {
schematic.renderingLayer = MathHelper.clamp(schematic.renderingLayer - 1, 0, schematic.getHeight() - 1);
RenderSchematic.INSTANCE.refresh();
}
if (key == LAYER_TOGGLE.getKey())
if (schematic != null) {
schematic.layerMode = SchematicWorld.LayerMode.next(schematic.layerMode);
RenderSchematic.INSTANCE.refresh();
}
if (key == RENDER_TOGGLE.getKey())
if (schematic != null) {
schematic.isRendering = !schematic.isRendering;
RenderSchematic.INSTANCE.refresh();
}
if (key == MOVE_HERE.getKey())
if (schematic != null) {
ClientProxy.moveSchematicToPlayer(schematic);
RenderSchematic.INSTANCE.refresh();
}
if (key == PICK_BLOC.getKey())
if (schematic != null && schematic.isRendering) {
pickBlock(schematic, ClientProxy.objectMouseOver);
}
}
}
Aggregations