Package Hexel.blocks.types

Examples of Hexel.blocks.types.Block


    page.setColor(color);
    page.fillRect(startX, this.h-20, (int)(width*value), 6);
  }

  private void drawCurrentBlock(Graphics2D page) {
    Block b = this.player.getBlockToPlace();
    if (b == null)
      return;
    int availability = this.player.getBlockAvailability(b.getClass());

    int i = b.getTopTextureIndex();
    int texW = this.tex.getWidth() / TextureAtlas.HOR;
    int texH = this.tex.getHeight() / TextureAtlas.VER;
    int texX = i % TextureAtlas.HOR * texW;
    int texY = i / TextureAtlas.HOR * texH;

 
View Full Code Here


    //    final HashSet<Vector3i> seen = new HashSet<Vector3i>();

    BlockTools.pointFloodSearch(start, true, new BlockTools.PointFloodSearchMatcher() {
      @Override
      public boolean matches(Vector3i p) {
        Block b = chunks.getBlock(p.x, p.y, p.z, tmp3i, chunk);
        if (!(b instanceof BlockTransparent)){
          return false;
        }
        if (blockDeltaAdder.hasBlockDelta(p)){
          return false;
        }
        if (!inSimRange.pointIsInRange(p)){
          return false;
        }
        BlockTransparent be = (BlockTransparent)b;
        int newLightLevel = 0;
        int highestBlock = chunks.getHighestBlockAtXY(p.x, p.y, tmp2i, highestBlockChunk);

        if (p.z > highestBlock){
          newLightLevel = 0;
        }
        else {
          Vector3i[] neighbors = HexGeometry.getAllNeighbors(p.x);
          int highestNeighborLightLevel = BlockTransparent.MAX_LIGHT_LEVEL;
          for (Vector3i neighbor3 : neighbors) {
            tmp3i2.x = p.x+neighbor3.x;
            tmp3i2.y = p.y+neighbor3.y;
            tmp3i2.z = p.z+neighbor3.z;
            Block neighbor = chunks.getBlock(tmp3i2.x, tmp3i2.y, tmp3i2.z, tmp3i, chunk);
            if (neighbor instanceof BlockTransparent){
              int naturalOcclusion = 1;
              if (neighbor3.z == 1)
                naturalOcclusion = 0;
              BlockTransparent neighborE = (BlockTransparent)neighbor;
View Full Code Here

      for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 32; z++) {
          int gx = cx * 32 + x;
          int gy = cy * 16 + y;
          int gz = cz * 32 + z;
          Block b = this.tm.getBlock(gx, gy, gz, tmp);
          chunk.set(x, y, z, b);
          chunk.stepsToSim[x][y][z] = 100;
          chunk.nextSimSteps[x][y][z] = -1;
          if (!(b instanceof BlockTransparent))
            chunks.updateHighestBlockAtXY(gx, gy, gz, tmp);
View Full Code Here

    int index = 0;
    for (int x = 0; x < 32; x++) {
      for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 32; z++) {
          Block block = this.chunk.get(x, y, z);
          if (block instanceof BlockEmpty)
            continue;
          int px = x / 2;
          if (x % 2 == 0) {
            HexGeometry.hexToCartesian(px, y, a);
            HexGeometry.hexToCartesian(px, y + 1, b);
            HexGeometry.hexToCartesian(px + 1, y, c);
            HexGeometry.hexToCartesian(px + 0.5, y + 0.5, d);
          } else {
            HexGeometry.hexToCartesian(px + 1, y + 1, a);
            HexGeometry.hexToCartesian(px, y + 1, b);
            HexGeometry.hexToCartesian(px + 1, y, c);
            HexGeometry.hexToCartesian(px + 0.5, y + 0.5, d);
          }

          Block blockZP = this.chunks.getBlock(this.chunk.cx, this.chunk.cy,
              this.chunk.cz, x, y, z + 1, tmp, chunk);
          boolean displayZP = display(block, blockZP, Face.TOP);

          Block blockZM = this.chunks.getBlock(this.chunk.cx, this.chunk.cy,
              this.chunk.cz, x, y, z - 1, tmp, chunk);
          boolean displayZM = display(block, blockZM, Face.BOTTOM);

          // NOTE faces wrong but it doesn't matter here, see below
          // for correct
          Block blockXP = this.chunks.getBlock(this.chunk.cx, this.chunk.cy,
              this.chunk.cz, x + 1, y, z, tmp, chunk);
          boolean displayXP = display(block, blockXP, Face.SIDEA);

          Block blockXM = this.chunks.getBlock(this.chunk.cx, this.chunk.cy,
              this.chunk.cz, x - 1, y, z, tmp, chunk);
          boolean displayXM = display(block, blockXM, Face.SIDEB);

          Block blockYP = this.chunks.getBlock(this.chunk.cx, this.chunk.cy,
              this.chunk.cz, x - 1, y + 1, z, tmp, chunk);
          boolean displayYP = display(block, blockYP, Face.SIDEC);

          Block blockYM = this.chunks.getBlock(this.chunk.cx, this.chunk.cy,
              this.chunk.cz, x + 1, y - 1, z, tmp, chunk);
          boolean displayYM = display(block, blockYM, Face.SIDEB);

          double fracBottom = block.getFracBottom();
          double fracTop = block.getFracTop();
View Full Code Here

    lowestWaterPoint.contents = null;
//    System.out.println("HWG " + step);
    BlockTools.pointFloodSearch(start, new BlockTools.PointFloodSearchMatcher() {
      @Override
      public boolean matches(Vector3i p) {
        Block b = chunks.getBlock(p.x, p.y, p.z, tmp3i, c);
        if (numSeen > 100){
          return false;
        }

//        if (b instanceof BlockEmpty && p.z == bz) {
View Full Code Here

      }
    }
    bcx /= n;
    bcy /= n;

    Block b;
    if (index < menuItems.length)
      b = gb;
    else
      b = db;

    int i = b.getTopTextureIndex();
    int texW = this.tex.getWidth() / TextureAtlas.HOR;
    int texH = this.tex.getHeight() / TextureAtlas.VER;
    int texX = i % TextureAtlas.HOR * texW;
    int texY = i / TextureAtlas.HOR * texH;
    BufferedImage subtex = this.tex.getSubimage(texX, texY, texW, texH);
View Full Code Here

      private Vector3i tmp = new Vector3i();

      @Override
      public boolean blockMatches(int x, int y, int z, Block b, Chunk c, HighestBlockChunk hbc, Chunks chunks, int steps) {
        Block ab = chunks.getBlock(x, y, z+1, tmp, c);
        return ab instanceof BlockEmpty;
      }

      @Override
      public void spawn(double x, double y, double z, int bx, int by, int bz, int step, Chunk c, Chunks chunks) {
        if (engine.thingSimulator.getNumberOfThingsOfType(Deer.class) < 10){
          Deer deer = new Deer(x, y, z, engine.getThingBridge());
          engine.addThing(deer);
        }
      }
    });

    dirtRules.add(new SpawnBlockRule(engine, 100){

      private Vector3i tmp = new Vector3i();

      @Override
      public boolean blockMatches(int x, int y, int z, Block b, Chunk c, HighestBlockChunk hbc, Chunks chunks, int steps) {
        Block ab = chunks.getBlock(x, y, z+1, tmp, c);
        return ab instanceof BlockEmpty;
      }

      @Override
      public void spawn(double x, double y, double z, int bx, int by, int bz, int step, Chunk c, Chunks chunks) {
        Block ab = chunks.getBlock(bx, by, bz+1, tmp, c);
        BlockTransparent abt = (BlockTransparent)ab;
        int numberToSpawn = engine.zsp.getNumberToSpawn();
        if (numberToSpawn <= 0)
          return;
        double lightLevel = engine.getAmbientLight() - abt.naturalLightLevel*1.0/BlockTransparent.MAX_LIGHT_LEVEL;
 
View Full Code Here

          Vector3i[] neighbors = HexGeometry.getAllNeighbors(bx);
          Vector3i neighbor = neighbors[neighborIndex];
          BlockWood wb = (BlockWood) b;
          if (!wb.data.alive)
            return false;
          Block nb = chunks.getBlock(bx + neighbor.x, by + neighbor.y, bz + neighbor.z, tmp3i, c);
          if (!(nb instanceof BlockEmpty || nb instanceof BlockLeaf))
            return false;
         
          int nx = bx + neighbor.x;
          int ny = by + neighbor.y;
View Full Code Here

  public boolean canApply(int bx, int by, int bz, boolean fastMode, Block b, Chunk c,
      HighestBlockChunk hbc, Chunks chunks, int step, BlockDeltaAdder blockDeltaAdder) {
    BlockDirt bd = (BlockDirt)b;
    if (bd.hasGrass)
      return false;
    Block ab = chunks.getBlock(bx, by, bz+1, tmp3i, c);
    if (!(ab instanceof BlockEmpty))
      return false;
    Vector2i[] neighbors = HexGeometry.getNeighbors(bx);
    for (int i = 0; i < neighbors.length; i++){
      int nx = bx + neighbors[i].x;
      int ny = by + neighbors[i].y;
      Block nb = chunks.getBlock(nx, ny, bz, tmp3i, c);
      if (nb instanceof BlockDirt && ((BlockDirt)nb).hasGrass){
        return true;
      }
    }
    return false;
View Full Code Here

TOP

Related Classes of Hexel.blocks.types.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.