Package Hexel.chunk

Source Code of Hexel.chunk.Chunk

package Hexel.chunk;

import Hexel.LogData;
import Hexel.blocks.types.Block;
import Hexel.math.HexGeometry;
import Hexel.math.Vector3i;

public class Chunk implements java.io.Serializable {
  /**
   *
   */
  private static final long serialVersionUID = -5209559940184823447L;
  public static int WIDTH = 32;
  public static int HEIGHT = 16;
  public static int DEPTH = 32;

  private Vector3i pos;

  private boolean dirty;
  public boolean isDirty(){ return dirty; }
  public void setDirty(boolean dirty){
    this.dirty = dirty;
  }


  public boolean modified;
  public boolean beingUpdated = false;
  public boolean needFirstSim;

  public int nextSimStep;
 
  private Block[][][] blocks = new Block[32][16][32];
  public int[][][] stepsToSim = new int[32][16][32];
  public int[][][] nextSimSteps = new int[32][16][32];
 
  public boolean fastMode = false;

  public int cx;
  public int cy;
  public int cz;

  public Chunk(int cx, int cy, int cz) {
    this.cx = cx;
    this.cy = cy;
    this.cz = cz;
    this.pos = new Vector3i(cx, cy, cz);
  }

  public Block get(int x, int y, int z) {
    return this.blocks[x][y][z];
  }

  public Block getGlobal(int x, int y, int z, Vector3i tmp){
    HexGeometry.globalToLocal(x, y, z, tmp);
    return this.get(tmp.x, tmp.y, tmp.z);

  }

  public void set(int x, int y, int z, Block b) {
    this.blocks[x][y][z] = b;
  }

  public boolean containsPoint(int x, int y, int z){
    return x >= cx*32 && x < (cx+1)*32 &&
        y >= cy*16 && y < (cy+1)*16 &&
        z >= cz*32 && z < (cz+1)*32;
  }

  public Vector3i getXYZ() {
    return this.pos;
  }
}
TOP

Related Classes of Hexel.chunk.Chunk

TOP
Copyright © 2018 www.massapi.com. 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.