Search in sources :

Example 6 with SchematicWorld

use of com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.

the class OverlayHandler method onText.

@SubscribeEvent
public void onText(final RenderGameOverlayEvent.Text event) {
    if (this.minecraft.gameSettings.showDebugInfo && SchematicaConfig.INSTANCE.showDebugInfo.getValue()) {
        final SchematicWorld schematic = ClientProxy.schematic;
        if (schematic != null && schematic.isRendering) {
            final ArrayList<String> left = event.getLeft();
            final ArrayList<String> right = event.getRight();
            left.add("");
            left.add(SCHEMATICA_PREFIX + schematic.getDebugDimensions());
            left.add(SCHEMATICA_PREFIX + RenderSchematic.INSTANCE.getDebugInfoTileEntities());
            left.add(SCHEMATICA_PREFIX + RenderSchematic.INSTANCE.getDebugInfoRenders());
            final RayTraceResult rtr = ClientProxy.objectMouseOver;
            if (rtr != null && rtr.typeOfHit == RayTraceResult.Type.BLOCK) {
                final BlockPos pos = rtr.getBlockPos();
                final IBlockState blockState = schematic.getBlockState(pos);
                right.add("");
                right.add(String.valueOf(Block.REGISTRY.getNameForObject(blockState.getBlock())) + SCHEMATICA_SUFFIX);
                for (final String formattedProperty : BlockStateHelper.getFormattedProperties(blockState)) {
                    right.add(formattedProperty + SCHEMATICA_SUFFIX);
                }
                final BlockPos offsetPos = pos.add(schematic.position);
                String lookMessage = String.format("Looking at: %d %d %d (%d %d %d)", pos.getX(), pos.getY(), pos.getZ(), offsetPos.getX(), offsetPos.getY(), offsetPos.getZ());
                if (this.minecraft.objectMouseOver != null && this.minecraft.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK) {
                    final BlockPos origPos = this.minecraft.objectMouseOver.getBlockPos();
                    if (offsetPos.equals(origPos)) {
                        lookMessage += " (matches)";
                    }
                }
                left.add(SCHEMATICA_PREFIX + lookMessage);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) SchematicWorld(com.github.lunatrius.schematica.client.world.SchematicWorld) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with SchematicWorld

use of com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.

the class WorldHandler method onLoad.

@SubscribeEvent
public void onLoad(final WorldEvent.Load event) {
    final World world = event.getWorld();
    if (world.isRemote && !(world instanceof SchematicWorld)) {
        RenderSchematic.INSTANCE.setWorldAndLoadRenderers(ClientProxy.schematic);
        addWorldAccess(world, RenderSchematic.INSTANCE);
    }
}
Also used : SchematicWorld(com.github.lunatrius.schematica.client.world.SchematicWorld) SchematicWorld(com.github.lunatrius.schematica.client.world.SchematicWorld) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with SchematicWorld

use of com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.

the class ClientProxy method loadSchematic.

@Override
public boolean loadSchematic(final EntityPlayer player, final File directory, final String filename) {
    final ISchematic schematic = SchematicFormat.readFromFile(directory, filename);
    if (schematic == null) {
        return false;
    }
    final SchematicWorld world = new SchematicWorld(schematic);
    Reference.logger.debug("Loaded {} [w:{},h:{},l:{}]", filename, world.getWidth(), world.getHeight(), world.getLength());
    ClientProxy.schematic = world;
    RenderSchematic.INSTANCE.setWorldAndLoadRenderers(world);
    // SchematicPrinter.INSTANCE.setSchematic(world);
    world.isRendering = true;
    return true;
}
Also used : ISchematic(com.github.lunatrius.schematica.api.ISchematic) SchematicWorld(com.github.lunatrius.schematica.client.world.SchematicWorld)

Example 9 with SchematicWorld

use of com.github.lunatrius.schematica.client.world.SchematicWorld in project Spark-Client by Spark-Client-Development.

the class SchematicRenderChunkVbo 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);
}
Also used : CompiledChunk(net.minecraft.client.renderer.chunk.CompiledChunk) SchematicWorld(com.github.lunatrius.schematica.client.world.SchematicWorld) BlockPos(net.minecraft.util.math.BlockPos) SetVisibility(net.minecraft.client.renderer.chunk.SetVisibility)

Aggregations

SchematicWorld (com.github.lunatrius.schematica.client.world.SchematicWorld)9 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 BlockPos (net.minecraft.util.math.BlockPos)4 IBlockState (net.minecraft.block.state.IBlockState)2 CompiledChunk (net.minecraft.client.renderer.chunk.CompiledChunk)2 SetVisibility (net.minecraft.client.renderer.chunk.SetVisibility)2 World (net.minecraft.world.World)2 ISchematic (com.github.lunatrius.schematica.api.ISchematic)1 GuiSchematicControl (com.github.lunatrius.schematica.client.gui.control.GuiSchematicControl)1 GuiSchematicLoad (com.github.lunatrius.schematica.client.gui.load.GuiSchematicLoad)1 CompiledOverlay (com.github.lunatrius.schematica.client.renderer.chunk.CompiledOverlay)1 Block (net.minecraft.block.Block)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 VisGraph (net.minecraft.client.renderer.chunk.VisGraph)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 ChunkCache (net.minecraft.world.ChunkCache)1