本文整理汇总了Java中org.bukkit.block.BlockFace.values方法的典型用法代码示例。如果您正苦于以下问题:Java BlockFace.values方法的具体用法?Java BlockFace.values怎么用?Java BlockFace.values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.BlockFace
的用法示例。
在下文中一共展示了BlockFace.values方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFace
import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public BlockFace getFace(final Block block) {
BlockFace[] values = BlockFace.values();
for (BlockFace face : values) {
if ((this.getX() + face.getModX() == block.getX()) &&
(this.getY() + face.getModY() == block.getY()) &&
(this.getZ() + face.getModZ() == block.getZ())
) {
return face;
}
}
return null;
}
示例2: getBlockFace
import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static BlockFace getBlockFace(double x, double y, double z)
{
int ix = (int) Math.round(x);
int iy = (int) Math.round(y);
int iz = (int) Math.round(z);
for(BlockFace face : BlockFace.values())
if(face.getModX() == ix && face.getModY() == iy && face.getModZ() == iz)
return face;
return null;
}
示例3: onPlayerMove
import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
Location to = event.getTo();
Location from = event.getFrom();
World world = to.getWorld();
if (to.clone().add(0, -1, 0).getBlock().getType() != Material.REDSTONE_LAMP_ON)
return;
if (from.clone().add(0, -1, 0).getBlock().getType() == Material.REDSTONE_LAMP_ON)
return;
for (Block block : getPortalNear(world, to.getBlockX(), to.getBlockY(), to.getBlockZ())) {
for (BlockFace bf : BlockFace.values()) {
Block relative = block.getRelative(bf);
if (relative.getTypeId() == SIGN) {
// Specific server
Sign sign = (Sign) relative.getState();
Portal portal = null;
for (Portal po : Portal.getList()) {
if (WorldUtil.sameBlock(po.getSign().getBlock(), sign.getBlock())) {
portal = po;
break;
}
}
if (portal == null)
return;
if (portal.getCurrent().getStatus() == Status.CLOSED)
Chat.player(p, "&cThat server is currently unavailable!");
else
portal.getCurrent().connect(event.getPlayer());
portal.updateSign();
}
}
}
}