Beispiel #1
0
/** @author Immortius */
@API
public final class ChunkConstants {
  public static final int SIZE_X = 32;
  public static final int SIZE_Y = 64;
  public static final int SIZE_Z = 32;

  public static final int INNER_CHUNK_POS_FILTER_X = TeraMath.ceilPowerOfTwo(SIZE_X) - 1;
  public static final int INNER_CHUNK_POS_FILTER_Y = TeraMath.ceilPowerOfTwo(SIZE_Y) - 1;
  public static final int INNER_CHUNK_POS_FILTER_Z = TeraMath.ceilPowerOfTwo(SIZE_Z) - 1;

  public static final int POWER_X = TeraMath.sizeOfPower(SIZE_X);
  public static final int POWER_Y = TeraMath.sizeOfPower(SIZE_Y);
  public static final int POWER_Z = TeraMath.sizeOfPower(SIZE_Z);

  public static final byte MAX_LIGHT = 0x0f;
  public static final byte MAX_SUNLIGHT = 0x0f;
  public static final byte MAX_SUNLIGHT_REGEN = 63;
  public static final byte SUNLIGHT_REGEN_THRESHOLD = 48;

  public static final Vector3i CHUNK_POWER = new Vector3i(POWER_X, POWER_Y, POWER_Z);
  public static final Vector3i CHUNK_SIZE = new Vector3i(SIZE_X, SIZE_Y, SIZE_Z);
  public static final Vector3i INNER_CHUNK_POS_FILTER =
      new Vector3i(INNER_CHUNK_POS_FILTER_X, INNER_CHUNK_POS_FILTER_Y, INNER_CHUNK_POS_FILTER_Z);
  public static final Region3i CHUNK_REGION =
      Region3i.createFromMinAndSize(Vector3i.zero(), CHUNK_SIZE);

  public static final Vector3i LOCAL_REGION_EXTENTS = new Vector3i(1, 1, 1);

  private ChunkConstants() {}
}
  @Test
  public void cumulativeBorderCalculation() {
    WorldBuilder worldBuilder = new WorldBuilder(12L);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    worldBuilder.addProvider(new Facet3Provider());

    World world = worldBuilder.build();
    Region3i regionToGenerate = Region3i.createFromCenterExtents(new Vector3i(), 1);
    Region regionData = world.getWorldData(regionToGenerate);

    Facet3 facet3 = regionData.getFacet(Facet3.class);
    assertEquals(regionToGenerate, facet3.getWorldRegion());

    Facet1 facet1 = regionData.getFacet(Facet1.class);
    assertEquals(
        Region3i.createFromMinAndSize(new Vector3i(-2, -1, -2), new Vector3i(5, 3, 5)),
        facet1.getWorldRegion());

    Facet2 facet2 = regionData.getFacet(Facet2.class);
    assertEquals(
        Region3i.createFromMinAndSize(new Vector3i(-4, -1, -4), new Vector3i(9, 3, 9)),
        facet2.getWorldRegion());
  }