org.bukkit.block.Block.getChunk()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(124)

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

Block.getChunk介绍

[英]Gets the chunk which contains this block
[中]获取包含此块的块

代码示例

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public Chunk getChunk() {
  return base.getChunk();
}

代码示例来源:origin: elBukkit/MagicPlugin

@Override
public void prepare() {
  if (cloneSource != null && cloneTarget != null) {
    Block block = cloneTarget.getBlock();
    if (!block.getChunk().isLoaded()) {
      block.getChunk().load(true);
    }
  }
}

代码示例来源:origin: marcelo-mason/PreciousStones

/**
 * @param block
 */
public ChunkVec(Block block) {
  super(block.getChunk().getX(), 0, block.getChunk().getZ(), block.getWorld().getName());
}

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
  public org.bukkit.Chunk convertSpecial(Object value, Class<?> valueType, org.bukkit.Chunk def) {
    if (value instanceof Chunk) {
      return ((Chunk) value).bukkitChunk;
    } else if (value instanceof org.bukkit.block.Block) {
      return ((org.bukkit.block.Block) value).getChunk();
    } else if (value instanceof BlockState) {
      return ((BlockState) value).getChunk();
    } else if (value instanceof Location) {
      return ((Location) value).getChunk();
    } else {
      return def;
    }
  }
};

代码示例来源:origin: elBukkit/MagicPlugin

@Override
public boolean isReady() {
  if ((mode == BrushMode.CLONE || mode == BrushMode.REPLICATE) && materialTarget != null) {
    Block block = materialTarget.getBlock();
    return (block.getChunk().isLoaded());
  } else if (mode == BrushMode.SCHEMATIC) {
    return checkSchematic();
  }
  return true;
}

代码示例来源:origin: elBukkit/MagicPlugin

public static boolean setBlockFast(Block block, Material material, int data) {
  return setBlockFast(block.getChunk(), block.getX(), block.getY(), block.getZ(), material, data);
}

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

@Override
  public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
    if (e.getClickedBlock() == null) return false;
    SlimefunItem item = BlockStorage.check(e.getClickedBlock());
    if (item == null || !item.getName().equals("GPS_GEO_SCANNER")) return false;
    e.setCancelled(true);
    try {
      Slimefun.getGPSNetwork().scanChunk(p, e.getClickedBlock().getChunk());
    } catch (Exception e1) {
      e1.printStackTrace();
    }
    return true;
  }
});

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

public Block getHeadTarget() {
 if (this.targetHeadBlock == null) {
  return null;
 }
 this.getTargetHeadBlock().getBlock().getChunk().load(true);
 return this.getTargetHeadBlock().getBlock();
}

代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common

public Block getHeadTarget() {
 if (this.targetHeadBlock == null) {
  return null;
 }
 this.getTargetHeadBlock().getBlock().getChunk().load(true);
 return this.getTargetHeadBlock().getBlock();
}

代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common

public Block getFeetTarget() {
 if (this.getTargetFeetBlock() == null) {
  return null;
 }
 this.getTargetFeetBlock().getBlock().getChunk().load(true);
 return this.getTargetFeetBlock().getBlock();
}

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

public Block getFeetTarget() {
 if (this.getTargetFeetBlock() == null) {
  return null;
 }
 this.getTargetFeetBlock().getBlock().getChunk().load(true);
 return this.getTargetFeetBlock().getBlock();
}

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

public static Item findItem(Block b) {
  for (Entity n: b.getChunk().getEntities()) {
    if (n instanceof Item) {
      if (b.getLocation().add(0.5, 1.2, 0.5).distanceSquared(n.getLocation()) < 0.5D && n.getCustomName() != null) return (Item) n;
    }
  }
  return null;
}

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

public void closeDoors() {
  // get door locations
  ResultSetDoorBlocks rs = new ResultSetDoorBlocks(plugin, id);
  if (rs.resultSet()) {
    close(rs.getOuterBlock(), rs.getInnerBlock().getLocation());
    // inner
    if (!rs.getInnerBlock().getChunk().isLoaded()) {
      rs.getInnerBlock().getChunk().load();
    }
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> close(rs.getInnerBlock(), null), 5L);
  }
}

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

public void openDoors() {
  // get door locations
  // inner
  ResultSetDoorBlocks rs = new ResultSetDoorBlocks(plugin, id);
  if (rs.resultSet()) {
    open(rs.getInnerBlock(), rs.getOuterBlock(), true);
    // outer
    if (!rs.getOuterBlock().getChunk().isLoaded()) {
      rs.getOuterBlock().getChunk().load();
    }
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> open(rs.getOuterBlock(), rs.getInnerBlock(), false), 5L);
  }
}

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

@Override
public boolean canOpen(Block b, Player p) {
  if (!(p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true))) {
    return false;
  }
  
  if (!OreGenSystem.wasResourceGenerated(OreGenSystem.getResource("Oil"), b.getChunk())) {
    Messages.local.sendTranslation(p, "gps.geo.scan-required", true);
    return false;
  }
  return true;
}

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

@Override
public boolean canOpen(Block b, Player p) {
  if (!(p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true))) {
    return false;
  }
  
  if (!OreGenSystem.wasResourceGenerated(getOreGenResource(), b.getChunk())) {
    Messages.local.sendTranslation(p, "gps.geo.scan-required", true);
    return false;
  }
  return true;
}

代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common

public boolean isDead(Game game) {
 Material targetMaterial = game.getTargetMaterial();
 this.getTargetHeadBlock().getBlock().getChunk().load(true);
 if (this.getTargetFeetBlock() == null) {
  return this.getTargetHeadBlock().getBlock().getType() != targetMaterial;
 }
 this.getTargetFeetBlock().getBlock().getChunk().load(true);
 return (this.getTargetHeadBlock().getBlock().getType() != targetMaterial
   && this.getTargetFeetBlock().getBlock().getType() != targetMaterial);
}

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

public boolean isDead(Game game) {
 Material targetMaterial = game.getTargetMaterial();
 this.getTargetHeadBlock().getBlock().getChunk().load(true);
 if (this.getTargetFeetBlock() == null) {
  return this.getTargetHeadBlock().getBlock().getType() != targetMaterial;
 }
 this.getTargetFeetBlock().getBlock().getChunk().load(true);
 return (this.getTargetHeadBlock().getBlock().getType() != targetMaterial
   && this.getTargetFeetBlock().getBlock().getType() != targetMaterial);
}

代码示例来源:origin: elBukkit/MagicPlugin

public RegenerateBatch(UndoableSpell spell, Location p1, Location p2) {
  super(spell);
  this.restoredBlocks = new com.elmakers.mine.bukkit.block.UndoList(mage, spell.getName());
  this.restoredBlocks.setSpell(spell);
  this.restoredBlocks.setBatch(this);
  this.world = this.mage.getLocation().getWorld();
  this.state = RegenerateState.SAVING;
  int deltax = p2.getBlock().getChunk().getX() - p1.getChunk().getX();
  int deltaz = p2.getChunk().getZ() - p1.getChunk().getZ();
  absx = Math.abs(deltax) + 1;
  absz = Math.abs(deltaz) + 1;
  dx = (int)Math.signum(deltax);
  dz = (int)Math.signum(deltaz);
  x = p1.getChunk().getX();
  z = p1.getChunk().getZ();
  bounds = new BoundingBox(p1.toVector(), p2.toVector());
}

代码示例来源:origin: CitizensDev/CitizensAPI

@Override
public void teleport(Location location, TeleportCause cause) {
  if (!isSpawned())
    return;
  NPCTeleportEvent event = new NPCTeleportEvent(this, location);
  Bukkit.getPluginManager().callEvent(event);
  if (event.isCancelled())
    return;
  Entity entity = getEntity();
  while (entity.getVehicle() != null) {
    entity = entity.getVehicle();
  }
  location.getBlock().getChunk();
  teleport(entity, location, 5);
}

相关文章