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


Java WorldEntitySpawner类代码示例

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


WorldEntitySpawner类属于net.minecraft.world包,在下文中一共展示了WorldEntitySpawner类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: findDarkSpot

import net.minecraft.world.WorldEntitySpawner; //导入依赖的package包/类
private BlockPos findDarkSpot() {
    IMeeCreep entity = helper.getMeeCreep();
    World world = entity.getWorld();
    AxisAlignedBB box = getActionBox();
    return GeneralTools.traverseBoxFirst(box, p -> {
        if (world.isAirBlock(p) && WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, p)) {
            int light = world.getLightFromNeighbors(p);
            if (light < 7) {
                return p;
            }
        }
        return null;
    });
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:15,代码来源:LightupActionWorker.java

示例4: findDarkSpot

import net.minecraft.world.WorldEntitySpawner; //导入依赖的package包/类
private BlockPos findDarkSpot() {
    World world = helper.getMeeCreep().getWorld();
    BlockPos position = options.getPlayer().getPosition();
    AxisAlignedBB box = new AxisAlignedBB(position.add(-6, -4, -6), position.add(6, 4, 6));
    return GeneralTools.traverseBoxFirst(box, p -> {
        if (world.isAirBlock(p) && WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, p)) {
            int light = world.getLightFromNeighbors(p);
            if (light < 7) {
                return p;
            }
        }
        return null;
    });
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:15,代码来源:FollowAndLightupActionWorker.java

示例5: isPossible

import net.minecraft.world.WorldEntitySpawner; //导入依赖的package包/类
@Override
    public boolean isPossible(World world, BlockPos pos, EnumFacing side) {
        // @todo config for area
        AxisAlignedBB box = new AxisAlignedBB(pos.add(-10, -5, -10), pos.add(10, 5, 10));
//        AxisAlignedBB box = new AxisAlignedBB(pos.add(-2, -2, -2), pos.add(2, 2, 2));
        return GeneralTools.traverseBoxTest(box, p -> {
            if (WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, p)) {
                int light = world.getLightFromNeighbors(p);
                if (light < 7) {
                    return true;
                }
            }
            return false;
        });
    }
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:16,代码来源:LightupActionFactory.java

示例6: 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

示例7: 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

示例8: 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

示例9: populate

import net.minecraft.world.WorldEntitySpawner; //导入依赖的package包/类
@Override
public void populate(int chunkX, int chunkZ)
{
	int x = chunkX * 16;
	int z = chunkZ * 16;

	BlockPos pos = new BlockPos(x, 0, z);

	Biome biome = this.worldObj.getBiome(pos.add(16, 0, 16));

	this.rand.setSeed(this.worldObj.getSeed());
       long l1 = (this.rand.nextLong() / 2L) * 2L + 1L;
       long l2 = (this.rand.nextLong() / 2L) * 2L + 1L;
       this.rand.setSeed((long)chunkX * l1 + (long)chunkZ * l2 ^ this.worldObj.getSeed());

	biome.decorate(this.worldObj, this.rand, pos);

   	if (gumCount < 800)
   	{
   		++gumCount;
   	}
   	else if (this.rand.nextInt(100) == 0)
   	{
   		boolean resetCounter = false;
   		
   		resetCounter = this.golden_island.generate(this.worldObj, this.rand, pos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(64) + 32, this.rand.nextInt(16) + 8));

   		if (resetCounter)
   		{
   			gumCount = 0;
   		}
   	}

	if (this.rand.nextInt(3) == 0)
       {
        this.dungeon_bronze.generate(this.worldObj, this.rand, pos.add(this.rand.nextInt(16), this.rand.nextInt(64) + 32, this.rand.nextInt(16)));
       }

	if(this.rand.nextInt(500) == 0)
	{
		BlockPos newPos = pos.add(this.rand.nextInt(16), this.rand.nextInt(32) + 64, this.rand.nextInt(16));

        this.dungeon_silver.generate(this.worldObj, this.rand, newPos);
	}

	WorldEntitySpawner.performWorldGenSpawning(this.worldObj, biome, x + 8, z + 8, 16, 16, this.rand);
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:48,代码来源:ChunkProviderAether.java

示例10: 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

示例11: populate

import net.minecraft.world.WorldEntitySpawner; //导入依赖的package包/类
@Override
public void populate(int chunkX, int chunkZ) {
    BlockFalling.fallInstantly = true;
    int x = chunkX * 16;
    int z = chunkZ * 16;
    BlockPos pos = new BlockPos(x, 0, z);
    Biome biome = this.world.getBiome(pos.add(16, 0, 16));
    this.random.setSeed(this.world.getSeed());
    long k = this.random.nextLong() / 2L * 2L + 1L;
    long l = this.random.nextLong() / 2L * 2L + 1L;
    this.random.setSeed((long) chunkX * k + (long) chunkZ * l ^ this.world.getSeed());
    boolean generatedVillage = false;

    if (this.decorate) {
        ForgeEventFactory.onChunkPopulate(true, this, this.world, this.random, chunkX, chunkZ, generatedVillage);

        biome.decorate(this.world, this.random, new BlockPos(x, 0, z));
        if (TerrainGen.populate(this, this.world, this.random, chunkX, chunkZ, generatedVillage, PopulateChunkEvent.Populate.EventType.ANIMALS)) {
            WorldEntitySpawner.performWorldGenSpawning(this.world, biome, x + 8, z + 8, 16, 16, this.random);
        }
        pos = pos.add(8, 0, 8);

        if (TerrainGen.populate(this, this.world, this.random, chunkX, chunkZ, generatedVillage, PopulateChunkEvent.Populate.EventType.ICE)) {
            for (int offsetX = 0; offsetX < 16; ++offsetX) {
                for (int offsetZ = 0; offsetZ < 16; ++offsetZ) {
                    BlockPos snowPos = this.world.getPrecipitationHeight(pos.add(offsetX, 0, offsetZ));
                    BlockPos groundPos = snowPos.down();

                    if (this.world.canBlockFreezeWater(groundPos)) {
                        this.world.setBlockState(groundPos, Blocks.ICE.getDefaultState(), 2);
                    }

                    if (this.world.canSnowAt(snowPos, true)) {
                        this.world.setBlockState(snowPos, Blocks.SNOW_LAYER.getDefaultState(), 2);
                    }
                }
            }
        }

        ForgeEventFactory.onChunkPopulate(false, this, this.world, this.random, chunkX, chunkZ, generatedVillage);
    }

    BlockFalling.fallInstantly = false;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:45,代码来源:ChunkGeneratorEarth.java

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