org.bukkit.Chunk类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.bukkit.Chunk类的一些代码示例,展示了Chunk类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Chunk类的具体详情如下:
包路径:org.bukkit.Chunk
类名称:Chunk

Chunk介绍

[英]Represents a chunk of blocks
[中]表示一块块块

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
  public void populate(World world, Random random, Chunk chunk) {
    int sourceX = chunk.getX() << 4;
    int sourceZ = chunk.getZ() << 4;
    for (int i = 0; i < random.nextInt(3); i++) {
      int x = sourceX + random.nextInt(16);
      int z = sourceZ + random.nextInt(16);
      int y = world.getHighestBlockYAt(x, z);
      new StoneBoulder().generate(world, random, x, y, z);
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

private GlowItem getFirstDroppedItem(Location location) {
  for (Entity entity : location.getChunk().getEntities()) {
    if (location.getBlockX() != entity.getLocation().getBlockX()
      || location.getBlockY() != entity.getLocation().getBlockY()
      || location.getBlockZ() != entity.getLocation().getBlockZ()) {
      continue;
    }
    if (entity.getType() != EntityType.DROPPED_ITEM) {
      continue;
    }
    return ((GlowItem) entity);
  }
  return null;
}

代码示例来源:origin: Bukkit/Bukkit

protected ChunkEvent(final Chunk chunk) {
  super(chunk.getWorld());
  this.chunk = chunk;
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
  public void populate(World world, Random random, Chunk chunk) {
    obsidianPillarDecorator.populate(world, random, chunk);

    // spawn the enderdragon
    if (chunk.getX() == 0 && chunk.getZ() == 0) {
      final Location loc = new Location(world, (chunk.getX() << 4) + 8, 128,
        (chunk.getZ() << 4) + 8, random.nextFloat() * 360, 0);
      world.spawnEntity(loc, EntityType.ENDER_DRAGON);
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

public static Key to(Chunk chunk) {
  return of(chunk.getX(), chunk.getZ());
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
  public void populate(World world, Random random, Chunk chunk) {
    int sourceX = chunk.getX() << 4;
    int sourceZ = chunk.getZ() << 4;

    for (int i = 0; i < random.nextInt(6) + 3; i++) {
      int x = sourceX + random.nextInt(16);
      int z = sourceZ + random.nextInt(16);
      int y = random.nextInt(28) + 4;

      if (world.getBlockAt(x, y, z).getType() == Material.STONE) {
        world.getBlockAt(x, y, z).setType(Material.EMERALD_ORE);
      }
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
  public void decorate(World world, Random random, Chunk source) {
    int sourceX = (source.getX() << 4) + random.nextInt(16);
    int sourceZ = (source.getZ() << 4) + random.nextInt(16);
    int sourceY = world.getHighestBlockYAt(sourceX, sourceZ) - 1;
    while (
      world.getBlockAt(sourceX, sourceY - 1, sourceZ).getType() == Material.STATIONARY_WATER
        ||
        world.getBlockAt(sourceX, sourceY - 1, sourceZ).getType() == Material.WATER
          && sourceY > 1) {
      sourceY--;
    }
    Material material = world.getBlockAt(sourceX, sourceY, sourceZ).getType();
    if (material == Material.STATIONARY_WATER || material == Material.WATER) {
      new BlockPatch(type, horizRadius, vertRadius, overridables)
        .generate(world, random, sourceX, sourceY, sourceZ);
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void decorate(World world, Random random, Chunk source) {
  int sourceX = (source.getX() << 4) + random.nextInt(16);
  int sourceZ = (source.getZ() << 4) + random.nextInt(16);
  int sourceY = flowing ? 4 + random.nextInt(120) : 10 + random.nextInt(108);
  Block block = world.getBlockAt(sourceX, sourceY, sourceZ);
  if ((block.getType() != Material.NETHERRACK && !block.isEmpty())
      || block.getRelative(BlockFace.UP).getType() != Material.NETHERRACK) {
    return;

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void populate(World world, Random random, Chunk chunk) {
  GlowServer server = (GlowServer) Bukkit.getServer();
  boolean allowAnimals = world.getAllowAnimals() && server.getAnimalsSpawnEnabled();
  boolean allowMonsters = world.getAllowMonsters() && server.getMonstersSpawnEnabled();
  if (entityTypes.length == 0) {
    return;
  if (random.nextFloat() >= rarity) {
    return;
  int sourceX = chunk.getX() << 4;
  int sourceZ = chunk.getZ() << 4;
  EntityType type = entityTypes[random.nextInt(entityTypes.length)];
  if ((!allowAnimals && Animals.class.isAssignableFrom(type.getEntityClass()))
      || !allowMonsters && Monster.class.isAssignableFrom(type.getEntityClass())) {
    return;
  int centerX = sourceX + random.nextInt(16);
  int centerZ = sourceZ + random.nextInt(16);
  int count = minGroup == maxGroup ? minGroup
    Location location = block.getLocation().clone().add(0, 1, 0);
    location.setYaw(random.nextFloat() * 360 - 180);
    if (location.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void decorate(World world, Random random, Chunk source) {
  int sourceX = (source.getX() << 4) + random.nextInt(16);
  int sourceZ = (source.getZ() << 4) + random.nextInt(16);
  Block sourceBlock = world
      .getBlockAt(sourceX, world.getHighestBlockYAt(sourceX, sourceZ), sourceZ);
  BiFunction<Random, BlockStateDelegate, ? extends GenericTree> ctor
      = getRandomTree(random, trees);
  if (ctor != null) {
    BlockStateDelegate delegate = new BlockStateDelegate();
    GenericTree tree;
    try {
      tree = ctor.apply(random, delegate);
    } catch (Exception ex) {
      tree = new GenericTree(random, delegate);
    }
    if (tree.generate(sourceBlock.getLocation())) {
      delegate.updateBlockStates();
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void populate(World world, Random random, Chunk chunk) {
  int cx = chunk.getX() << 4;
  int cz = chunk.getZ() << 4;
  for (Entry<OreType, Integer> entry : ores.entrySet()) {
    OreType oreType = entry.getKey();
    for (int n = 0; n < entry.getValue(); n++) {
      int sourceX = cx + random.nextInt(16);
      int sourceZ = cz + random.nextInt(16);
      int sourceY = oreType.getRandomHeight(random);
      new OreVein(oreType).generate(world, random, sourceX, sourceY, sourceZ);
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
  public void decorate(World world, Random random, Chunk source) {
    if (random.nextInt(type == Material.STATIONARY_WATER ? 4 : 8) == 0) {
      int sourceX = (source.getX() << 4) + random.nextInt(16);
      int sourceZ = (source.getZ() << 4) + random.nextInt(16);
      int sourceY = random
        .nextInt(type == Material.STATIONARY_WATER ? 256 : random.nextInt(248) + 8);
      if (type == Material.STATIONARY_LAVA && (sourceY >= world.getSeaLevel()
        || random.nextInt(10) > 0)) {
        return;
      }
      while (world.getBlockAt(sourceX, sourceY, sourceZ).isEmpty() && sourceY > 5) {
        sourceY--;
      }
      if (sourceY >= 5) {
        new Lake(type).generate(world, random, sourceX, sourceY, sourceZ);
      }
    }
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public void populate(World world, Random random, Chunk source) {
  if (world.canGenerateStructures()) {
    int cx = source.getX();
    int cz = source.getZ();
    random.setSeed(world.getSeed());
    long randX = random.nextLong();
    long randZ = random.nextLong();
        if (!world.getChunkAt(x, z).isLoaded() && !world.getChunkAt(x, z).load(true)) {
          continue;

代码示例来源:origin: TheBusyBiscuit/Slimefun4

private static ArmorStand getArmorStand(Block b) {
  Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() - 0.7F, b.getZ() + 0.5);
  
  for (Entity n: l.getChunk().getEntities()) {
    if (n instanceof ArmorStand) {
      if (n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
    }
  }
  
  ArmorStand hologram = ArmorStandFactory.createHidden(l);
  return hologram;
}

代码示例来源:origin: eccentricdevotion/TARDIS

private Location getRelativeLocation(Player p) {
  Location playerLoc = p.getLocation();
  double x = vortexJunkLoc.getX() + (playerLoc.getX() - junkLoc.getX());
  double y = vortexJunkLoc.getY() + (playerLoc.getY() - junkLoc.getY()) + 0.5d;
  double z = vortexJunkLoc.getZ() + (playerLoc.getZ() - junkLoc.getZ());
  Location l = new Location(vortexJunkLoc.getWorld(), x, y, z, playerLoc.getYaw(), playerLoc.getPitch());
  while (!l.getChunk().isLoaded()) {
    l.getChunk().load();
  }
  return l;
}

代码示例来源:origin: TheBusyBiscuit/Slimefun4

public static ArmorStand getArmorStand(Location reactor) {
  Location l = new Location(reactor.getWorld(), reactor.getX() + 0.5, reactor.getY(), reactor.getZ() + 0.5);
  for (Entity n : l.getChunk().getEntities()) {
    if (n instanceof ArmorStand) {
      if (l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
    }
  }
  ArmorStand hologram = ArmorStandFactory.createHidden(l);
  hologram.setCustomNameVisible(false);
  hologram.setCustomName(null);
  return hologram;
}

代码示例来源:origin: GlowstoneMC/Glowstone

Chunk locationChunk = location.getChunk();
if (locationChunk.getX() == chunk.getX() && locationChunk.getZ() == chunk.getZ()) {
  int tileX = location.getBlockX();
  int tileY = location.getBlockY();
  int tileZ = location.getBlockZ();
  String type = ItemIds.getName(location.getBlock().getType());
  CompoundTag tag = new CompoundTag();
  tag.putInt("x", tileX);

代码示例来源:origin: bitquest/bitquest

String spawnKey(Location location) {
 return location.getWorld().getName()
   + location.getChunk().getX()
   + ","
   + location.getChunk().getZ()
   + "spawn";
}

代码示例来源:origin: jiongjionger/NeverLag

public ChunkInfo(Chunk chunk) {
  this.world = chunk.getWorld().getName();
  this.chunkx = chunk.getX();
  this.chunkz = chunk.getZ();
}

代码示例来源:origin: eccentricdevotion/TARDIS

private int getChunkX(boolean min, Chunk c) {
  int cx = c.getX();
  int cz = c.getZ();
  if (min) {
    return c.getWorld().getChunkAt(cx - 4, cz).getBlock(0, 64, 0).getX();
  } else {
    return c.getWorld().getChunkAt(cx + 4, cz).getBlock(0, 64, 0).getX();
  }
}

相关文章