本文整理汇总了Java中org.bukkit.block.BlockFace.getModZ方法的典型用法代码示例。如果您正苦于以下问题:Java BlockFace.getModZ方法的具体用法?Java BlockFace.getModZ怎么用?Java BlockFace.getModZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.BlockFace
的用法示例。
在下文中一共展示了BlockFace.getModZ方法的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));
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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+")");
}
示例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();
}
示例8: fromBlockFace
import org.bukkit.block.BlockFace; //导入方法依赖的package包/类
public static Vector3d fromBlockFace(BlockFace face)
{
return new Vector3d(face.getModX(), face.getModY(), face.getModZ());
}
示例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());
}