当前位置: 首页>>代码示例>>Java>>正文


Java Area.neighbourBlockCoordinates方法代码示例

本文整理汇总了Java中ethanjones.cubes.world.storage.Area.neighbourBlockCoordinates方法的典型用法代码示例。如果您正苦于以下问题:Java Area.neighbourBlockCoordinates方法的具体用法?Java Area.neighbourBlockCoordinates怎么用?Java Area.neighbourBlockCoordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ethanjones.cubes.world.storage.Area的用法示例。


在下文中一共展示了Area.neighbourBlockCoordinates方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkDirt

import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
private void checkDirt(World world, Area area, int x, int y, int z) {
  if (x < 0 || x >= Area.SIZE_BLOCKS || z < 0 || z >= Area.SIZE_BLOCKS) {
    Area a = area.neighbourBlockCoordinates(x + area.minBlockX, z + area.minBlockZ);
    if (a == null) return;
    if (Lock.tryToLock(true, a)) {
      int bX = (x + area.minBlockX) - a.minBlockX;
      int bZ = (z + area.minBlockZ) - a.minBlockZ;
      if (a.getBlock(bX, y, bZ) == Blocks.dirt && validGrass(world, a, bX, y, bZ, false)) {
        a.setBlock(Blocks.grass, bX, y, bZ, 0);
      }
      a.lock.writeUnlock();
    }
  } else {
    if (area.getBlock(x, y, z) == Blocks.dirt && validGrass(world, area, x, y, z, false)) {
      area.setBlock(Blocks.grass, x, y, z, 0);
    }
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:19,代码来源:BlockGrass.java

示例2: setBlock

import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
protected void setBlock(Area area, Block block, int x, int y, int z, int meta) {
	if (area.minBlockX > x || area.minBlockX + Area.SIZE_BLOCKS <= x || area.minBlockZ > z
			|| area.minBlockZ + Area.SIZE_BLOCKS <= z) {
		area = area.neighbourBlockCoordinates(x, z);
	}
	area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, meta);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:8,代码来源:TreeGenerator.java

示例3: randomTickMeta

import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
private int randomTickMeta(int x, int z, Area a, Area area, int meta) {
	if (x < 0 || x >= Area.SIZE_BLOCKS || z < 0 || z >= Area.SIZE_BLOCKS) {
		a = area.neighbourBlockCoordinates(x + area.minBlockX, z + area.minBlockZ);
		if (a == null) {
			return meta;
			// otherwise leaves may decay if area containing log is
			// not loaded
		}
		x = x + area.minBlockX - a.minBlockX;
		z = z + area.minBlockZ - a.minBlockZ;
	}
	return meta;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:14,代码来源:BlockLeaves.java

示例4: randomTick

import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
@Override
public int randomTick(World world, Area area, final int blockX, final int blockY, final int blockZ, int meta) {
  if (meta == 1) {
    HashSet<BlockReference> checked = new HashSet<BlockReference>();
    ArrayDeque<BlockReference> todo = new ArrayDeque<BlockReference>();
    BlockReference start = new BlockReference().setFromBlockCoordinates(blockX, blockY, blockZ);
    todo.add(start.copy().offset(-1, 0, 0));
    todo.add(start.copy().offset(1, 0, 0));
    todo.add(start.copy().offset(0, -1, 0));
    todo.add(start.copy().offset(0, 1, 0));
    todo.add(start.copy().offset(0, 0, -1));
    todo.add(start.copy().offset(0, 0, 1));
    while (!todo.isEmpty()) {
      BlockReference poll = todo.poll();
      int x = poll.blockX, y = poll.blockY, z = poll.blockZ;
      Area a = area;
      if (x < 0 || x >= Area.SIZE_BLOCKS || z < 0 || z >= Area.SIZE_BLOCKS) {
        a = area.neighbourBlockCoordinates(x + area.minBlockX, z + area.minBlockZ);
        if (a == null) return meta; //otherwise leaves may decay if area containing log is not loaded
        x = x + area.minBlockX - a.minBlockX;
        z = z + area.minBlockZ - a.minBlockZ;
      }
      if (y < 0 || y > a.maxY) continue;
      Block b = a.getBlock(x, y, z);
      if (b == Blocks.leaves) {
        add(checked, todo, start, poll, -1, 0, 0);
        add(checked, todo, start, poll, 1, 0, 0);
        add(checked, todo, start, poll, 0, -1, 0);
        add(checked, todo, start, poll, 0, 1, 0);
        add(checked, todo, start, poll, 0, 0, -1);
        add(checked, todo, start, poll, 0, 0, 1);
      } else if (b == Blocks.log) {
        return meta;
      }
    }
    area.setBlock(null, blockX, blockY, blockZ, 0);
    dropItems(Cubes.getServer().world, blockX + area.minBlockX, blockY, blockZ + area.minBlockZ, meta);
  }
  return meta;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:41,代码来源:BlockLeaves.java

示例5: setNeighbour

import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
public static void setNeighbour(Area area, Block block, int x, int y, int z, int meta) {
  Area a = area.neighbourBlockCoordinates(x, z);
  set(a, block, x - a.minBlockX, y, z - a.minBlockZ, meta);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:5,代码来源:TerrainGenerator.java

示例6: setVisibleNeighbour

import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
public static void setVisibleNeighbour(Area area, Block block, int x, int y, int z, int meta) {
  Area a = area.neighbourBlockCoordinates(x, z);
  setVisible(a, block, x - a.minBlockX, y, z - a.minBlockZ, meta);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:5,代码来源:TerrainGenerator.java

示例7: setBlock

import ethanjones.cubes.world.storage.Area; //导入方法依赖的package包/类
protected void setBlock(Area area, Block block, int x, int y, int z, int meta) {
  if (area.minBlockX > x || area.minBlockX + Area.SIZE_BLOCKS <= x || area.minBlockZ > z || area.minBlockZ + Area.SIZE_BLOCKS <= z) {
    area = area.neighbourBlockCoordinates(x, z);
  }
  area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, meta);
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:7,代码来源:TreeGenerator.java


注:本文中的ethanjones.cubes.world.storage.Area.neighbourBlockCoordinates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。