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


Java BlockFace.getModX方法代码示例

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


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

示例1: excludeFaceCoordinate

import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static Vector2d excludeFaceCoordinate(Vector3d vector, BlockFace face)
	{
		if(!isCardinal(face))
			throw new IllegalArgumentException("Cannot exclude coordinate from non-cardinal BlockFace");
		
		if(face.getModX() != 0)
			return new Vector2d(vector.y(), vector.z());
		if(face.getModY() != 0)
			return new Vector2d(vector.x(), vector.z());
		if(face.getModZ() != 0)
			return new Vector2d(vector.x(), vector.y());
		throw new IllegalStateException("Unexpected BlockFace coordinates. ("+face+")");
		
//		List<Float> values = vector.getGetters().stream().map(Supplier::get).collect(Collectors.toList());
//		values.remove(getAxisIndex(face));
//		return Vector2f.create(values.get(0), values.get(1));
	}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:18,代码来源:BukkitUtils.java

示例2: mergeFaceCoordinate

import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static Vector3d mergeFaceCoordinate(Vector2d excluded, double extracted, BlockFace face)
	{
		if(!isCardinal(face))
			throw new IllegalArgumentException("Cannot merge coordinates from non-cardinal BlockFace");
		if(face.getModX() != 0)
			return new Vector3d(extracted, excluded.x(), excluded.y());
		if(face.getModY() != 0)
			return new Vector3d(excluded.x(), extracted, excluded.y());
		if(face.getModZ() != 0)
			return new Vector3d(excluded.x(), excluded.y(), extracted);
		throw new IllegalStateException("Unexpected BlockFace coordinates. ("+face+")");
//		List<Float> values = new ArrayList<>(Arrays.asList(excluded.getX(), excluded.getY()));
//		int axis = getAxisIndex(face);
//		values.add(axis, extracted);
//		return Vector3f.create(values.get(0), values.get(1), values.get(2));
	}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:17,代码来源:BukkitUtils.java

示例3: getDirection

import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
/**
 * Get the direction "to" is relative to "from".
 * @param from
 * @param to
 * @return direction
 */
public static BlockFace getDirection(Location from, Location to) {
    double dis = 0;
    BlockFace ret = BlockFace.SELF;
    for (BlockFace face : FACES) {
        if (face == BlockFace.SELF)
            continue;

        Location sub = to.clone().subtract(from.getX(), from.getY(), from.getZ());
        double tDis = (sub.getX() * face.getModX()) + (sub.getZ() * face.getModZ());
        if (tDis >= dis) {
            dis = tDis;
            ret = face;
        }
    }
    return ret;
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:23,代码来源:Utils.java

示例4: 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;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:15,代码来源:CraftBlock.java

示例5: 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;
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:12,代码来源:BukkitUtils.java

示例6: getAxisIndex

import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static int getAxisIndex(BlockFace face)
{
	if(!isCardinal(face))
		throw new IllegalArgumentException("Non-cardinal BlockFace has more than one axis.");
	
	if(face.getModX() != 0)
		return 0;
	if(face.getModY() != 0)
		return 1;
	if(face.getModZ() != 0)
		return 2;
	throw new IllegalStateException("Unexpected BlockFace coordinates. ("+face+")");
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:14,代码来源:BukkitUtils.java

示例7: extractFaceCoordinate

import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static double extractFaceCoordinate(Vector3d vector, BlockFace face)
	{
		if(!isCardinal(face))
			throw new IllegalArgumentException("Cannot extract coordinate from non-cardinal BlockFace");
		
		if(face.getModX() != 0)
			return vector.x();
		if(face.getModY() != 0)
			return vector.y();
		if(face.getModZ() != 0)
			return vector.z();
		throw new IllegalStateException("Unexpected BlockFace coordinates. ("+face+")");
//		return vector.getGetters().get(getAxisIndex(face)).get();
	}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:15,代码来源:BukkitUtils.java

示例8: fromBlockFace

import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static Vector3d fromBlockFace(BlockFace face)
{
	return new Vector3d(face.getModX(), face.getModY(), face.getModZ());
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:5,代码来源:BukkitUtils.java

示例9: getRelative

import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static BlockVector getRelative(BlockVector pos, BlockFace face) {
    return new BlockVector(pos.getBlockX() + face.getModX(),
                           pos.getBlockY() + face.getModY(),
                           pos.getBlockZ() + face.getModZ());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:BlockFaces.java


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