本文整理汇总了Java中net.minecraft.server.EntityHanging.survives方法的典型用法代码示例。如果您正苦于以下问题:Java EntityHanging.survives方法的具体用法?Java EntityHanging.survives怎么用?Java EntityHanging.survives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.server.EntityHanging
的用法示例。
在下文中一共展示了EntityHanging.survives方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFacingDirection
import net.minecraft.server.EntityHanging; //导入方法依赖的package包/类
public boolean setFacingDirection(BlockFace face, boolean force) {
EntityHanging hanging = getHandle();
EnumDirection dir = hanging.direction;
switch (face) {
case SOUTH:
default:
getHandle().setDirection(EnumDirection.SOUTH);
break;
case WEST:
getHandle().setDirection(EnumDirection.WEST);
break;
case NORTH:
getHandle().setDirection(EnumDirection.NORTH);
break;
case EAST:
getHandle().setDirection(EnumDirection.EAST);
break;
}
if (!force && !hanging.survives()) {
// Revert since it doesn't fit
hanging.setDirection(dir);
return false;
}
return true;
}
示例2: setFacingDirection
import net.minecraft.server.EntityHanging; //导入方法依赖的package包/类
public boolean setFacingDirection(BlockFace face, boolean force) {
Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing());
EntityHanging hanging = getHandle();
int x = hanging.x, y = hanging.y, z = hanging.z, dir = hanging.direction;
hanging.x = block.getX();
hanging.y = block.getY();
hanging.z = block.getZ();
switch (face) {
case SOUTH:
default:
getHandle().setDirection(0);
break;
case WEST:
getHandle().setDirection(1);
break;
case NORTH:
getHandle().setDirection(2);
break;
case EAST:
getHandle().setDirection(3);
break;
}
if (!force && !hanging.survives()) {
// Revert since it doesn't fit
hanging.x = x;
hanging.y = y;
hanging.z = z;
hanging.setDirection(dir);
return false;
}
return true;
}