Пример #1
0
  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 :
        (Iterable<BlockPos.MutableBlockPos>)
            BlockPos.getAllInBoxMutable(posChunk, posChunk.add(15, 15, 15))) {
      if (this.world.getBlockState(mutableBlockPos).getBlock().isOpaqueCube()) {
        visgraph.func_178606_a(mutableBlockPos);
      }
    }

    return visgraph.func_178609_b(pos);
  }
Пример #2
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());
  }