本文整理汇总了Java中org.bukkit.material.Rails类的典型用法代码示例。如果您正苦于以下问题:Java Rails类的具体用法?Java Rails怎么用?Java Rails使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Rails类属于org.bukkit.material包,在下文中一共展示了Rails类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isBusy
import org.bukkit.material.Rails; //导入依赖的package包/类
public static boolean isBusy(final Block block, final Block other) {
// Check to see if both sides of a rail block have rails. If they do, assume we're connected.
Rails data = (Rails) block.getState().getData();
BlockFace bf = data.getDirection().getOppositeFace();
BlockFace face1, face2;
if ( bf == BlockFace.NORTH_EAST ) {
face1 = BlockFace.NORTH;
face2 = BlockFace.EAST;
} else if ( bf == BlockFace.NORTH_WEST ) {
face1 = BlockFace.NORTH;
face2 = BlockFace.WEST;
} else if ( bf == BlockFace.SOUTH_EAST ) {
face1 = BlockFace.SOUTH;
face2 = BlockFace.EAST;
} else if ( bf == BlockFace.SOUTH_WEST ) {
face1 = BlockFace.SOUTH;
face2 = BlockFace.WEST;
} else {
face1 = bf;
face2 = bf.getOppositeFace();
}
final Block block1 = block.getRelative(face1);
final Block block2 = block.getRelative(face2);
return !( block1.equals(other) || block2.equals(other) ) && isRail(block1) && isRail(block2);
}
示例2: getBearing
import org.bukkit.material.Rails; //导入依赖的package包/类
@Override
public BlockFace getBearing() {
if(isRail(block)) {
return ((Rails)block).getDirection();
}
return null;
}
示例3: getConnectedSide
import org.bukkit.material.Rails; //导入依赖的package包/类
public static Block getConnectedSide(Location location, BlockFace side)
{
// int x = location.getBlockX();
// int y = location.getBlockY();
// int z = location.getBlockZ();
Block block = location.getBlock().getRelative(side);
Block b = location.getBlock();
Bukkit.getLogger().info("Block: " + block.getX() + ", " + block.getY() + ", " + block.getZ());
Bukkit.getLogger().info("Side block: " + b.getX() + ", " + b.getY() + ", " + b.getZ());
switch (block.getType())
{
// case 50:
//case 65:
// case 75:
//case 76:
// case 68:
// case 69:
// case 77:
// case 96:
case TORCH:
case LADDER:
case WALL_SIGN:
case LEVER:
case REDSTONE_TORCH_ON:
case REDSTONE_TORCH_OFF:
case STONE_BUTTON:
case WOOD_BUTTON:
case TRAP_DOOR:
case IRON_TRAPDOOR:
case WALL_BANNER:
BlockFace face = ((Attachable) (block.getState().getData())).getAttachedFace().getOppositeFace();
if (b.getRelative(face).getX() == block.getX() && b.getRelative(face).getZ() == block.getZ())
{
return block;
}
return null;
case TRIPWIRE_HOOK:
BlockFace face2 = ((Directional) (block.getState().getData())).getFacing().getOppositeFace();
if (b.getRelative(face2).getX() == block.getX() && b.getRelative(face2).getZ() == block.getZ())
{
return block;
}
return null;
//case 27:
//case 28:
//case 66:
case RAILS:
case ACTIVATOR_RAIL:
case DETECTOR_RAIL:
case POWERED_RAIL:
Rails rail = (Rails) block.getState().getData();
if (rail.isOnSlope())
{
BlockFace face1 = rail.getDirection().getOppositeFace();
if (b.getRelative(face1).getX() == block.getX() && b.getRelative(face1).getZ() == block.getZ())
{
return block;
}
}
default:
return null;
}
}
示例4: Rails
import org.bukkit.material.Rails; //导入依赖的package包/类
public Rails() {
}
示例5: clone
import org.bukkit.material.Rails; //导入依赖的package包/类
public Rails clone() {
return null;
}
示例6: run
import org.bukkit.material.Rails; //导入依赖的package包/类
@Override
public void run() {
// If the event was cancelled, stop right now.
if ( event.isCancelled() )
return;
// If the block isn't still a rail, abort.
if ( !BlockUtils.isRail(block) )
return;
// Get the block state.
BlockState bs = block.getState();
Rails data = (Rails) bs.getData();
// Find the first portal and stick to it.
for(final ABPortal portal: portals) {
BlockFace face = portal.getFace(block);
if ( face == null )
continue;
// Try finding a rail block.
Block target = null;
boolean sloped = false;
// First, look ahead.
Block other = block.getRelative(face);
if ( (BlockUtils.isRail(other) && !BlockUtils.isBusy(other, block)) || (BlockUtils.isRail(other.getRelative(BlockFace.DOWN)) && !BlockUtils.isBusy(other.getRelative(BlockFace.DOWN), block)) ) {
target = other;
} else {
// We can go up if it's straight away.
other = other.getRelative(BlockFace.UP);
if ( BlockUtils.isRail(other) && !BlockUtils.isBusy(other, block) ) {
target = other;
sloped = true;
} else {
// Check the sides.
BlockFace f = BlockUtils.toLeft(face);
other = block.getRelative(f);
if ( BlockUtils.isRail(other) && !BlockUtils.isBusy(other, block) && portal.getFace(other) == null ) {
target = other;
face = BlockUtils.toRightSub(face);
} else {
f = BlockUtils.toRight(face);
other = block.getRelative(f);
if ( BlockUtils.isRail(other) && !BlockUtils.isBusy(other, block) && portal.getFace(other) == null ) {
target = other;
face = BlockUtils.toLeftSub(face);
}
}
}
}
// Rotate this track.
data.setDirection(face, sloped);
bs.setData(data);
bs.update();
return;
}
}