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


Java World.getTopSolidOrLiquidBlock方法代码示例

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


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

示例1: flowerGenerator

import net.minecraft.world.World; //导入方法依赖的package包/类
private void flowerGenerator(BlockFlower flower, World worldIn, Random random, int chunkX, int chunkZ, float chancesToSpawn)
{
	for(int i = 0; i < chancesToSpawn; i++)
		if(random.nextFloat() < chancesToSpawn)
		{
			int x = chunkX * 16 + random.nextInt(16);
			int z = chunkZ * 16 + random.nextInt(16);
			BlockPos position = worldIn.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z));
			BlockPos blockpos = position.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
	
	        if (worldIn.isAirBlock(blockpos) && (worldIn.provider.isSurfaceWorld() || blockpos.getY() < 255) && 
	        		flower.canBlockStay(worldIn, blockpos, flower.getDefaultState()))
	        {
	            worldIn.setBlockState(blockpos,flower.getDefaultState(), 2);
	        }
		}

}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:19,代码来源:WorldGen.java

示例2: generate

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	//System.out.println("Generating "+bs+" at "+chunkX+", "+chunkZ);
	int x = random.nextInt(16);
	int z = random.nextInt(16);
	BlockPos pos = new BlockPos((chunkX*16)+x,0,(chunkZ*16)+z);
	pos = world.getTopSolidOrLiquidBlock(pos);
	//pos = pos.up();
	generate(world, random, pos);
}
 
开发者ID:trigg,项目名称:Firma,代码行数:11,代码来源:FirmaTree.java

示例3: gen

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
	random.setSeed(world.getSeed());
	long good = random.nextLong();
	long succ = random.nextLong();

	good *= x >> 3;
	succ *= z >> 3;
	random.setSeed(good * succ * world.getSeed());
	//Generate
	if(GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity > 0D
			&& GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity / 100D > random.nextDouble()) {
		List<AxisAlignedBB> occupied = Lists.newArrayList();
		for(int i = 0; i < GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.size; i++) {
			BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 0, z).toBlockPos());
			int below = random.nextInt(7);
			if(top.getY() > below) {
				top = top.add(0, -below, 0);
			}
			Template obelisk = obelisks.next().load(world);
			Rotation rotation = Rotation.values()[random.nextInt(4)];
			Vector3 vec = Vector3.create(obelisk.getSize()).rotate(rotation);
			AxisAlignedBB obeliskBB = new AxisAlignedBB(top, vec.add(top).toBlockPos()).grow(1);
			if(occupied.stream().noneMatch(bb -> bb.intersects(obeliskBB))) {
				PlacementSettings settings = new PlacementSettings();
				settings.setRotation(rotation);
				settings.setRandom(random);
				obelisk.addBlocksToWorld(world, top, settings);

				occupied.add(obeliskBB);
			}
		}
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:35,代码来源:ObeliskDecorator.java

示例4: performWorldGenSpawning

import net.minecraft.world.World; //导入方法依赖的package包/类
private void performWorldGenSpawning(World worldIn, EnumCreatureType type, BlockPos pos ,int p_77191_2_, int p_77191_3_, int p_77191_4_, int p_77191_5_, Random randomIn)
  {
  	float amount;
  	switch (type) {
case MONSTER:
	amount = 0.1f;
	break;
default:
	amount = 0.3f;
	break;
}
  	List<SpawnListEntry> enteries = world.getBiome(pos).getSpawnableList(type);
  	SpawnListEntry entry = enteries.get(rand.nextInt(enteries.size()));
  	while (randomIn.nextFloat() < amount)
      {
          int i = entry.minGroupCount + randomIn.nextInt(1 + entry.maxGroupCount - entry.minGroupCount);
          IEntityLivingData ientitylivingdata = null;
          int j = p_77191_2_ + randomIn.nextInt(p_77191_4_);
          int k = p_77191_3_ + randomIn.nextInt(p_77191_5_);
          int l = j;
          int i1 = k;

          for (int j1 = 0; j1 < i; ++j1)
          {
              boolean flag = false;

              for (int k1 = 0; !flag && k1 < 4; ++k1)
              {
                  BlockPos blockpos = worldIn.getTopSolidOrLiquidBlock(new BlockPos(j, 0, k));

                  if (WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, worldIn, blockpos))
                  {
                      EntityLiving entityliving;

                      try
                      {
                          entityliving = entry.newInstance(worldIn);
                      }
                      catch (Exception exception)
                      {
                          exception.printStackTrace();
                          continue;
                      }

                      entityliving.setLocationAndAngles((double)((float)j + 0.5F), (double)blockpos.getY(), (double)((float)k + 0.5F), randomIn.nextFloat() * 360.0F, 0.0F);
                      worldIn.spawnEntity(entityliving);
                      ientitylivingdata = entityliving.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityliving)), ientitylivingdata);
                      flag = true;
                  }

                  j += randomIn.nextInt(5) - randomIn.nextInt(5);

                  for (k += randomIn.nextInt(5) - randomIn.nextInt(5); j < p_77191_2_ || j >= p_77191_2_ + p_77191_4_ || k < p_77191_3_ || k >= p_77191_3_ + p_77191_4_; k = i1 + randomIn.nextInt(5) - randomIn.nextInt(5))
                  {
                      j = l + randomIn.nextInt(5) - randomIn.nextInt(5);
                  }
              }
          }
      }
  }
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:61,代码来源:PontusChunkProvider.java

示例5: getSamplePos

import net.minecraft.world.World; //导入方法依赖的package包/类
private BlockPos getSamplePos(World world, ChunkPos chunkPos)
{
    return world.getTopSolidOrLiquidBlock(new BlockPos((chunkPos.x << 4) + random.nextInt(16), 0, (chunkPos.z << 4) + random.nextInt(16)));
}
 
开发者ID:oitsjustjose,项目名称:Geolosys,代码行数:5,代码来源:ChunkData.java

示例6: gen

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
	random.setSeed(world.getSeed());
	long good = random.nextLong();
	long succ = random.nextLong();

	good *= x >> 2;
	succ *= z >> 2;
	random.setSeed(good * succ ^ world.getSeed());
	//Generate
	if (GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.rarity > 0D
			&& GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.rarity / 100D > random.nextDouble()) {
		BlockPos origin = new BlockPos(x, 0, z);
		//Gen Monolith
		BlockPos surface = world.getTopSolidOrLiquidBlock(origin.add(8, 0, 8));
		BlockPos pos = origin.add(5, Math.max(surface.getY() - (5 + random.nextInt(3)), 8), 4);
		Structure.MONOLITH_CUBE.generate(world, pos.down(7), new PlacementSettings());
		//Randomize glyphs
		Vector3 start = Vector3.create(pos).add(0,-4,6);
		Arrays.stream(EnumFacing.HORIZONTALS).forEach(facing -> {
			for (int i = 0; i < 6; i++) {
				IBlockState glyph = ModBlocks.MONOLITHIC_GLYPH.getDefaultState().withProperty(State.GLYPH, random.nextInt(16));
				world.setBlockState(start.toBlockPos(), glyph);
				start.offset(facing.getOpposite(), 1);
			}
		});
		//Add loot
		BlockPos loot = pos.down(7).add(1, 1, 1);
		for (int i = 0; i < 6 + random.nextInt(6); i++) {
			if (GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.loot / 100D > random.nextDouble()) {
				BlockPos inside = loot.add(random.nextInt(4), 0, random.nextInt(4));
				IBlockState pot = ModBlocks.LARGE_POT.getDefaultState().withProperty(State.POT_VARIANT, random.nextInt(3));
				world.setBlockState(inside, pot);
			}
		}
		//Gen ruin
		if (GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.well) {
			Structure.MONOLITH_RUIN.generate(world, pos, new PlacementSettings());
		}
		int size = random.nextInt(GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.size / 2);
		size += GEN_CONFIG.MONOLITH_CONFIG.MONOLITH_STRUCTURE.size / 2;
		for (int i = 0; i < size; i++) {
			BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 1, z).toBlockPos());
			int below = random.nextInt(3);
			if (top.getY() > below) {
				top = top.add(0, -below, 0);
			}
			world.setBlockState(top, ModBlocks.ASHEN.getDefaultState());
		}
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:52,代码来源:MonolithStructure.java


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