Example #1
0
  private void renderOverlay(final SchematicWorld schematic, final boolean isRenderingSchematic) {
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    final GeometryTessellator tessellator = GeometryTessellator.getInstance();
    tessellator.setTranslation(
        -ClientProxy.playerPosition.x,
        -ClientProxy.playerPosition.y,
        -ClientProxy.playerPosition.z);
    tessellator.setDelta(ConfigurationHandler.blockDelta);

    if (ClientProxy.isRenderingGuide) {
      tessellator.startQuads();
      tessellator.drawCuboid(ClientProxy.pointA, GeometryMasks.Quad.ALL, 0xBF0000, 0x3F);
      tessellator.drawCuboid(ClientProxy.pointB, GeometryMasks.Quad.ALL, 0x0000BF, 0x3F);
      tessellator.draw();
    }

    tessellator.startLines();
    if (ClientProxy.isRenderingGuide) {
      tessellator.drawCuboid(ClientProxy.pointA, GeometryMasks.Line.ALL, 0xBF0000, 0x3F);
      tessellator.drawCuboid(ClientProxy.pointB, GeometryMasks.Line.ALL, 0x0000BF, 0x3F);
      tessellator.drawCuboid(
          ClientProxy.pointMin, ClientProxy.pointMax, GeometryMasks.Line.ALL, 0x00BF00, 0x7F);
    }
    if (isRenderingSchematic) {
      this.tmp.set(
          schematic.position.x + schematic.getWidth() - 1,
          schematic.position.y + schematic.getHeight() - 1,
          schematic.position.z + schematic.getLength() - 1);
      tessellator.drawCuboid(schematic.position, this.tmp, GeometryMasks.Line.ALL, 0xBF00BF, 0x7F);
    }
    tessellator.draw();

    GlStateManager.depthMask(false);
    this.renderContainer.renderOverlay();
    GlStateManager.depthMask(true);

    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GlStateManager.disableBlend();
    GlStateManager.enableTexture2D();
  }
Example #2
0
  public boolean flip(final SchematicWorld world, final EnumFacing axis, final boolean forced) {
    if (world == null) {
      return false;
    }

    try {
      final ISchematic schematic = world.getSchematic();
      final Schematic schematicFlipped = flip(schematic, axis, forced);

      world.setSchematic(schematicFlipped);

      for (final TileEntity tileEntity : world.getTileEntities()) {
        world.initializeTileEntity(tileEntity);
      }

      return true;
    } catch (final FlipException fe) {
      Reference.logger.error(fe.getMessage());
    } catch (final Exception e) {
      Reference.logger.fatal("Something went wrong!", e);
    }

    return false;
  }
Example #3
0
  public void setWorldAndLoadRenderers(final SchematicWorld world) {
    if (this.world != null) {
      this.world.removeWorldAccess(this);
    }

    this.frustumUpdatePosX = Double.MIN_VALUE;
    this.frustumUpdatePosY = Double.MIN_VALUE;
    this.frustumUpdatePosZ = Double.MIN_VALUE;
    this.frustumUpdatePosChunkX = Integer.MIN_VALUE;
    this.frustumUpdatePosChunkY = Integer.MIN_VALUE;
    this.frustumUpdatePosChunkZ = Integer.MIN_VALUE;
    this.renderManager.set(world);
    this.world = world;

    if (world != null) {
      world.addWorldAccess(this);
      loadRenderers();
    }
  }
Example #4
0
  @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);
    generator.getLock().lock();
    RegionRenderCache regionRenderCache;
    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;
      }

      regionRenderCache =
          new RegionRenderCache(this.world, from.add(-1, -1, -1), to.add(1, 1, 1), 1);
      generator.setCompiledChunk(compiledOverlay);
    } finally {
      generator.getLock().unlock();
    }

    final VisGraph visgraph = new VisGraph();

    if (!regionRenderCache.extendedLevelsInChunkCache()) {
      ++renderChunksUpdated;

      final World mcWorld = Minecraft.getMinecraft().theWorld;

      final EnumWorldBlockLayer layer = EnumWorldBlockLayer.TRANSLUCENT;
      final WorldRenderer worldRenderer =
          generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(layer);

      GeometryTessellator.setStaticDelta(ConfigurationHandler.blockDelta);

      for (final BlockPos pos : BlockPos.getAllInBox(from, to)) {
        if (schematic.isRenderingLayer && schematic.renderingLayer != pos.getY()
            || !schematic.isInside(pos)) {
          continue;
        }

        boolean render = false;
        int sides = 0;
        int color = 0;

        final IBlockState schBlockState = schematic.getBlockState(pos);
        final Block schBlock = schBlockState.getBlock();

        if (schBlock.isOpaqueCube()) {
          visgraph.func_178606_a(pos);
        }

        final BlockPos mcPos = pos.add(schematic.position);
        final IBlockState mcBlockState = mcWorld.getBlockState(mcPos);
        final Block mcBlock = mcBlockState.getBlock();

        final boolean isSchAirBlock = schematic.isAirBlock(pos);
        final boolean isMcAirBlock =
            mcWorld.isAirBlock(mcPos) || ConfigurationHandler.isExtraAirBlock(mcBlock);

        if (!isMcAirBlock) {
          if (isSchAirBlock && ConfigurationHandler.highlightAir) {
            render = true;
            sides = GeometryMasks.Quad.ALL;
            color = 0xBF00BF;
          }
        }

        if (!render) {
          if (ConfigurationHandler.highlight) {
            if (!isMcAirBlock) {
              if (schBlock != mcBlock) {
                render = true;
                color = 0xFF0000;
              } else if (schBlock.getMetaFromState(schBlockState)
                  != mcBlock.getMetaFromState(mcBlockState)) {
                render = true;
                color = 0xBF5F00;
              }
            } else if (!isSchAirBlock) {
              render = true;
              color = 0x00BFFF;
            }
          }

          if (render) {
            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.DOWN), EnumFacing.DOWN)) {
              sides |= GeometryMasks.Quad.DOWN;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.UP), EnumFacing.UP)) {
              sides |= GeometryMasks.Quad.UP;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.NORTH), EnumFacing.NORTH)) {
              sides |= GeometryMasks.Quad.NORTH;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.SOUTH), EnumFacing.SOUTH)) {
              sides |= GeometryMasks.Quad.SOUTH;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.WEST), EnumFacing.WEST)) {
              sides |= GeometryMasks.Quad.WEST;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.EAST), EnumFacing.EAST)) {
              sides |= GeometryMasks.Quad.EAST;
            }
          }
        }

        if (render && sides != 0) {
          if (!compiledOverlay.isLayerStarted(layer)) {
            compiledOverlay.setLayerStarted(layer);
            preRenderBlocks(worldRenderer, from);
          }

          GeometryTessellator.drawCuboid(worldRenderer, pos, sides, 0x3F000000 | color);
          compiledOverlay.setLayerUsed(layer);
        }
      }

      if (compiledOverlay.isLayerStarted(layer)) {
        postRenderBlocks(layer, x, y, z, worldRenderer, compiledOverlay);
      }
    }

    compiledOverlay.setVisibility(visgraph.computeVisibility());
  }