當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。