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


Java WorldEntitySpawner.canCreatureTypeSpawnAtLocation方法代码示例

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


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

示例1: getSpawnType

import net.minecraft.world.WorldEntitySpawner; //导入方法依赖的package包/类
private static SpawnType getSpawnType(Chunk chunk, int x, int y, int z) {
    World world = chunk.getWorld();
    BlockPos pos = new BlockPos(x, y, z);

    if (!WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8)
        return SpawnType.NEVER;

    BlockPos p = new BlockPos(x, y , z);
    AxisAlignedBB aabb = new AxisAlignedBB(p);

    if (!world.checkNoEntityCollision(aabb) || !world.getEntitiesWithinAABBExcludingEntity(null, aabb).isEmpty() || world.containsAnyLiquid(aabb))
        return SpawnType.NEVER;

    if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8)
        return SpawnType.NIGHT_ONLY;
    return SpawnType.ALWAYS;
}
 
开发者ID:univrsal,项目名称:JustEnoughButtons,代码行数:18,代码来源:MobOverlayRenderer.java

示例2: getSpawnMode

import net.minecraft.world.WorldEntitySpawner; //导入方法依赖的package包/类
private static int getSpawnMode(Chunk chunk, int x, int y, int z) {
    World world = chunk.getWorld();
    BlockPos pos = new BlockPos(x, y, z);
    if (!WorldEntitySpawner.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) {
        return 0;
    }

    c.set(x + 0.2, y + 0.01, z + 0.2, x + 0.8, y + 1.8, z + 0.8);
    AxisAlignedBB aabb = c.aabb();
    if (!world.checkNoEntityCollision(aabb) || !world.getEntitiesWithinAABBExcludingEntity(null, aabb).isEmpty() || world.containsAnyLiquid(aabb)) {
        return 0;
    }

    if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) {
        return 1;
    }
    return 2;
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:19,代码来源:WorldOverlayRenderer.java

示例3: findRandomSpawnPos

import net.minecraft.world.WorldEntitySpawner; //导入方法依赖的package包/类
@Nullable
private Vec3d findRandomSpawnPos(BlockPos pos)
{
    for (int i = 0; i < 10; ++i)
    {
        BlockPos blockpos = pos.add(this.worldObj.rand.nextInt(16) - 8, this.worldObj.rand.nextInt(6) - 3, this.worldObj.rand.nextInt(16) - 8);

        if (this.theVillage.isBlockPosWithinSqVillageRadius(blockpos) && WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, this.worldObj, blockpos))
        {
            return new Vec3d((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
        }
    }

    return null;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:16,代码来源:VillageSiege.java

示例4: performWorldGenSpawning

import net.minecraft.world.WorldEntitySpawner; //导入方法依赖的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: canMonsterSpawnAt

import net.minecraft.world.WorldEntitySpawner; //导入方法依赖的package包/类
public static boolean canMonsterSpawnAt(int x, int y, int z) {
    //return SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.MONSTER, getWorld(), x,y,z); // < 1.8
    //return SpawnerAnimals.func_180267_a(EntityLiving.SpawnPlacementType.ON_GROUND, getWorld(), new BlockPos(x,y,z)); // 1.8
    EntityLiving.SpawnPlacementType type = EntityLiving.SpawnPlacementType.ON_GROUND;
    return WorldEntitySpawner.canCreatureTypeSpawnAtLocation(type, getWorld(), new BlockPos(x,y,z));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:7,代码来源:ZWrapper.java

示例6: canMobSpawn

import net.minecraft.world.WorldEntitySpawner; //导入方法依赖的package包/类
protected static boolean canMobSpawn(@Nonnull final BlockPos pos) {
	return WorldEntitySpawner.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, EnvironState.getWorld(),
			pos);
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:5,代码来源:LightLevelHUD.java

示例7: onItemUse

import net.minecraft.world.WorldEntitySpawner; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldObj, BlockPos posIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  ItemStack stack = player.getHeldItem(hand);
  if (side == null || posIn == null || side != EnumFacing.UP) {
    if (!worldObj.isRemote) {
      UtilChat.addChatMessage(player, "item.tool_spawn_inspect.up");
    }
    return super.onItemUse(player, worldObj, posIn, hand, side, hitX, hitY, hitZ);
  }
  boolean showOdds = player.isSneaking();
  if (!worldObj.isRemote) {
    ChunkProviderServer s = (ChunkProviderServer) worldObj.getChunkProvider();
    BlockPos pos = posIn.offset(side);
    Chunk chunk = worldObj.getChunkFromBlockCoords(pos);
    if (worldObj.getChunkProvider() instanceof ChunkProviderServer) {
      List<SpawnDetail> names = new ArrayList<SpawnDetail>();
      for (EnumCreatureType creatureType : EnumCreatureType.values()) {
        List<Biome.SpawnListEntry> list = s.getPossibleCreatures(creatureType, pos);
        for (Biome.SpawnListEntry entry : list) {
          if (WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntitySpawnPlacementRegistry.getPlacementForEntity(entry.entityClass), worldObj, pos)) {
            names.add(new SpawnDetail(entry, creatureType));
            //hack since witherskeleton is not its own class/entry, just a mob modifier like zombietypes or villagertypes
            if (entry.entityClass.equals(EntitySkeleton.class) && player.dimension == Const.Dimension.nether) {
              names.add(new SpawnDetail("WitherSkeleton", creatureType, entry.itemWeight));
            }
          }
        }
      }
      if (names.size() > 0) {
        String strLight = "Light: " + chunk.getLightSubtracted(pos, 0) + " (" + chunk.getLightFor(EnumSkyBlock.SKY, pos) + " sky, " + chunk.getLightFor(EnumSkyBlock.BLOCK, pos) + " block)";
        UtilChat.addChatMessage(player, strLight);
        Collections.sort(names, new Comparator<SpawnDetail>() {
          @Override
          public int compare(SpawnDetail o1, SpawnDetail o2) {
            return o1.getSortBy().compareTo(o2.getSortBy());
          }
        });
        List<String> csv = new ArrayList<String>();
        for (SpawnDetail detail : names) {
          csv.add(detail.toString(showOdds));
        }
        UtilChat.addChatMessage(player, String.join(", ", csv));
      }
      else {
        UtilChat.addChatMessage(player, "item.tool_spawn_inspect.empty");
      }
    }
  }
  player.getCooldownTracker().setCooldown(this, COOLDOWN);
  super.onUse(stack, player, worldObj, hand);
  return super.onItemUse(player, worldObj, posIn, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:53,代码来源:ItemSpawnInspect.java


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