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


Java ThreadRandom类代码示例

本文整理汇总了Java中ethanjones.cubes.core.util.ThreadRandom的典型用法代码示例。如果您正苦于以下问题:Java ThreadRandom类的具体用法?Java ThreadRandom怎么用?Java ThreadRandom使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: tick

import ethanjones.cubes.core.util.ThreadRandom; //导入依赖的package包/类
public void tick() {
	if (Side.isServer()) {
		AreaMap areaMap = areaMap();
		if (!featuresGenerated() || areaMap == null)
			return;
		ThreadRandom random = ThreadRandom.get();
		lock.writeLock();
		int updates = NUM_RANDOM_UPDATES * height;
		for (int i = 0; i < updates; i++) {
			int randomX = random.nextInt(SIZE_BLOCKS);
			int randomZ = random.nextInt(SIZE_BLOCKS);
			int randomY = random.nextInt(maxY + 1);
			randomTick(randomX, randomY, randomZ, areaMap);
		}
		for (BlockData blockData : blockDataList) {
			blockData.update();
		}
		lock.writeUnlock();
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:21,代码来源:Area.java

示例2: tick

import ethanjones.cubes.core.util.ThreadRandom; //导入依赖的package包/类
public void tick() {
  if (Side.isServer()) {
    AreaMap areaMap = areaMap();
    if (!featuresGenerated() || areaMap == null) return;
    ThreadRandom random = ThreadRandom.get();
    lock.writeLock();
    int updates = NUM_RANDOM_UPDATES * height;
    for (int i = 0; i < updates; i++) {
      int randomX = random.nextInt(SIZE_BLOCKS);
      int randomZ = random.nextInt(SIZE_BLOCKS);
      int randomY = random.nextInt(maxY + 1);
      randomTick(randomX, randomY, randomZ, areaMap);
    }
    for (BlockData blockData : blockDataList) {
      blockData.update();
    }
    lock.writeUnlock();
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:20,代码来源:Area.java

示例3: randomTick

import ethanjones.cubes.core.util.ThreadRandom; //导入依赖的package包/类
@Override
public int randomTick(World world, Area area, int x, int y, int z, int meta) {
	if ((world.isDay() && area.getSunlight(x, y + 1, z) >= 10) || area.getLight(x, y + 1, z) >= 10) {
		if (meta >= 7) {
			new TreeGenerator().generateTree(x + area.minBlockX, y, z + area.minBlockZ,
					3 + ThreadRandom.get().nextInt(3), area);
		} else {
			meta++;
		}
	}
	return meta;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:13,代码来源:BlockSapling.java

示例4: drops

import ethanjones.cubes.core.util.ThreadRandom; //导入依赖的package包/类
@Override
public ItemStack[] drops(World world, int x, int y, int z, int meta) {
	boolean sapling = ThreadRandom.get().nextInt(24) == 0;
	boolean leaves = ThreadRandom.get().nextInt(6) == 0;
	if (sapling && leaves) {
		return new ItemStack[] { new ItemStack(Blocks.sapling.getItemBlock()),
				new ItemStack(Blocks.leaves.getItemBlock()) };
	} else if (sapling) {
		return new ItemStack[] { new ItemStack(Blocks.sapling.getItemBlock()) };
	} else if (leaves) {
		return new ItemStack[] { new ItemStack(Blocks.leaves.getItemBlock()) };
	} else {
		return new ItemStack[0];
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:16,代码来源:BlockLeaves.java

示例5: randomTick

import ethanjones.cubes.core.util.ThreadRandom; //导入依赖的package包/类
@Override
public int randomTick(World world, Area area, int x, int y, int z, int meta) {
  if ((world.isDay() && area.getSunlight(x, y + 1, z) >= 10) || area.getLight(x, y + 1, z) >= 10) {
    if (meta >= 7) {
      new TreeGenerator().generateTree(x + area.minBlockX, y, z + area.minBlockZ, 3 + ThreadRandom.get().nextInt(3), area);
    } else {
      meta++;
    }
  }
  return meta;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:12,代码来源:BlockSapling.java

示例6: drops

import ethanjones.cubes.core.util.ThreadRandom; //导入依赖的package包/类
@Override
public ItemStack[] drops(World world, int x, int y, int z, int meta) {
  boolean sapling = ThreadRandom.get().nextInt(24) == 0;
  boolean leaves = ThreadRandom.get().nextInt(6) == 0;
  if (sapling && leaves) {
    return new ItemStack[]{new ItemStack(Blocks.sapling.getItemBlock()), new ItemStack(Blocks.leaves.getItemBlock())};
  } else if (sapling) {
    return new ItemStack[]{new ItemStack(Blocks.sapling.getItemBlock())};
  } else if (leaves) {
    return new ItemStack[]{new ItemStack(Blocks.leaves.getItemBlock())};
  } else {
    return new ItemStack[0];
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:15,代码来源:BlockLeaves.java


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