org.bukkit.block.BlockFace#EAST源码实例Demo

下面列出了org.bukkit.block.BlockFace#EAST 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Modern-LWC   文件: DoubleChestMatcher.java
public static BlockFace getNeighboringChestBlockFace(Chest chest) {
    if (chest.getType() == Chest.Type.SINGLE)
        return null;
    BlockFace face = chest.getFacing();
    switch (face) {
        case NORTH:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.EAST : BlockFace.WEST;
        case SOUTH:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.WEST : BlockFace.EAST;
        case EAST:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.SOUTH : BlockFace.NORTH;
        case WEST:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.NORTH : BlockFace.SOUTH;
        default:
            return null;
    }
}
 
源代码2 项目: Kettle   文件: Sign.java
/**
 * Gets the face that this block is attached on
 *
 * @return BlockFace attached to
 */
public BlockFace getAttachedFace() {
    if (isWallSign()) {
        byte data = getData();

        switch (data) {
            case 0x2:
                return BlockFace.SOUTH;

            case 0x3:
                return BlockFace.NORTH;

            case 0x4:
                return BlockFace.EAST;

            case 0x5:
                return BlockFace.WEST;
        }

        return null;
    } else {
        return BlockFace.DOWN;
    }
}
 
源代码3 项目: Kettle   文件: DirectionalContainer.java
public BlockFace getFacing() {
    byte data = getData();

    switch (data) {
        case 0x2:
            return BlockFace.NORTH;

        case 0x3:
            return BlockFace.SOUTH;

        case 0x4:
            return BlockFace.WEST;

        case 0x5:
        default:
            return BlockFace.EAST;
    }
}
 
源代码4 项目: Kettle   文件: PistonBaseMaterial.java
@Override
public BlockFace getFacing() {
    byte dir = (byte) (getData() & 7);

    switch (dir) {
        case 0:
            return BlockFace.DOWN;
        case 1:
            return BlockFace.UP;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.SOUTH;
        case 4:
            return BlockFace.WEST;
        case 5:
            return BlockFace.EAST;
        default:
            return BlockFace.SELF;
    }
}
 
源代码5 项目: Kettle   文件: Comparator.java
/**
 * Gets the direction this comparator is facing
 *
 * @return The direction this comparator is facing
 * @see BlockFace
 */
@Override
public BlockFace getFacing() {
    byte data = (byte) (getData() & 0x3);

    switch (data) {
        case 0x0:
        default:
            return BlockFace.NORTH;

        case 0x1:
            return BlockFace.EAST;

        case 0x2:
            return BlockFace.SOUTH;

        case 0x3:
            return BlockFace.WEST;
    }
}
 
源代码6 项目: Kettle   文件: Torch.java
/**
 * Gets the face that this block is attached on
 *
 * @return BlockFace attached to
 */
public BlockFace getAttachedFace() {
    byte data = getData();

    switch (data) {
        case 0x1:
            return BlockFace.WEST;

        case 0x2:
            return BlockFace.EAST;

        case 0x3:
            return BlockFace.NORTH;

        case 0x4:
            return BlockFace.SOUTH;

        case 0x5:
        default:
            return BlockFace.DOWN;
    }
}
 
源代码7 项目: Kettle   文件: PistonExtensionMaterial.java
public BlockFace getFacing() {
    byte dir = (byte) (getData() & 7);

    switch (dir) {
        case 0:
            return BlockFace.DOWN;
        case 1:
            return BlockFace.UP;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.SOUTH;
        case 4:
            return BlockFace.WEST;
        case 5:
            return BlockFace.EAST;
        default:
            return BlockFace.SELF;
    }
}
 
源代码8 项目: Kettle   文件: Diode.java
/**
 * Gets the direction this diode is facing
 *
 * @return The direction this diode is facing
 * @see BlockFace
 */
@Override
public BlockFace getFacing() {
    byte data = (byte) (getData() & 0x3);

    switch (data) {
        case 0x0:
        default:
            return BlockFace.NORTH;

        case 0x1:
            return BlockFace.EAST;

        case 0x2:
            return BlockFace.SOUTH;

        case 0x3:
            return BlockFace.WEST;
    }
}
 
源代码9 项目: Civs   文件: BlockImpl.java
@Override
public Block getRelative(BlockFace blockFace) {
    if (blockFace == BlockFace.NORTH) {
        return new BlockImpl(new Location(location.getWorld(), location.getX() + 1, location.getY(), location.getZ()));
    } else if (blockFace == BlockFace.EAST) {
        return new BlockImpl(new Location(location.getWorld(), location.getX(), location.getY(), location.getZ() + 1));
    } else if (blockFace == BlockFace.SOUTH) {
        return new BlockImpl(new Location(location.getWorld(), location.getX() - 1, location.getY(), location.getZ()));
    } else if (blockFace == BlockFace.WEST) {
        return new BlockImpl(new Location(location.getWorld(), location.getX(), location.getY(), location.getZ() - 1));
    }
    return new BlockImpl(new Location(location.getWorld(), location.getX(), location.getY() + 1, location.getZ()));
}
 
源代码10 项目: UhcCore   文件: RandomUtils.java
public static BlockFace randomAdjacentFace(){
	BlockFace[] faces = new BlockFace[]{
		BlockFace.DOWN,
		BlockFace.UP,
		BlockFace.EAST,
		BlockFace.WEST,
		BlockFace.NORTH,
		BlockFace.SOUTH
	};
	return faces[randomInteger(0,faces.length-1)];
}
 
源代码11 项目: CardinalPGM   文件: Flags.java
public static BlockFace yawToFace(float yaw) {
    BlockFace[] RADIAL = {
            BlockFace.NORTH, BlockFace.NORTH_NORTH_EAST, BlockFace.NORTH_EAST, BlockFace.EAST_NORTH_EAST,
            BlockFace.EAST, BlockFace.EAST_SOUTH_EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH_SOUTH_EAST,
            BlockFace.SOUTH, BlockFace.SOUTH_SOUTH_WEST, BlockFace.SOUTH_WEST, BlockFace.WEST_SOUTH_WEST,
            BlockFace.WEST, BlockFace.WEST_NORTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_NORTH_WEST
    };
    int i = Math.round((yaw + 360f)/ 22.5f);
    return RADIAL[(i + 8)% 16];
}
 
源代码12 项目: Kettle   文件: Lever.java
/**
 * Gets the face that this block is attached on
 *
 * @return BlockFace attached to
 */
public BlockFace getAttachedFace() {
    byte data = (byte) (getData() & 0x7);

    switch (data) {
        case 0x1:
            return BlockFace.WEST;

        case 0x2:
            return BlockFace.EAST;

        case 0x3:
            return BlockFace.NORTH;

        case 0x4:
            return BlockFace.SOUTH;

        case 0x5:
        case 0x6:
            return BlockFace.DOWN;

        case 0x0:
        case 0x7:
            return BlockFace.UP;

    }

    return null;
}
 
源代码13 项目: Kettle   文件: TripwireHook.java
public BlockFace getAttachedFace() {
    switch (getData() & 0x3) {
        case 0:
            return BlockFace.NORTH;
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.SOUTH;
        case 3:
            return BlockFace.WEST;
    }
    return null;
}
 
源代码14 项目: Kettle   文件: Rails.java
/**
 * @return the direction these tracks are set
 * <p>
 * Note that tracks are bidirectional and that the direction returned
 * is the ascending direction if the track is set on a slope. If it is
 * set as a curve, the corner of the track is returned.
 */
public BlockFace getDirection() {
    byte d = getConvertedData();

    switch (d) {
        case 0x0:
        default:
            return BlockFace.SOUTH;

        case 0x1:
            return BlockFace.EAST;

        case 0x2:
            return BlockFace.EAST;

        case 0x3:
            return BlockFace.WEST;

        case 0x4:
            return BlockFace.NORTH;

        case 0x5:
            return BlockFace.SOUTH;

        case 0x6:
            return BlockFace.NORTH_WEST;

        case 0x7:
            return BlockFace.NORTH_EAST;

        case 0x8:
            return BlockFace.SOUTH_EAST;

        case 0x9:
            return BlockFace.SOUTH_WEST;
    }
}
 
源代码15 项目: BedwarsRel   文件: Utils.java
public static BlockFace getCardinalDirection(Location location) {
  double rotation = (location.getYaw() - 90) % 360;
  if (rotation < 0) {
    rotation += 360.0;
  }
  if (0 <= rotation && rotation < 22.5) {
    return BlockFace.NORTH;
  } else if (22.5 <= rotation && rotation < 67.5) {
    return BlockFace.NORTH_EAST;
  } else if (67.5 <= rotation && rotation < 112.5) {
    return BlockFace.EAST;
  } else if (112.5 <= rotation && rotation < 157.5) {
    return BlockFace.SOUTH_EAST;
  } else if (157.5 <= rotation && rotation < 202.5) {
    return BlockFace.SOUTH;
  } else if (202.5 <= rotation && rotation < 247.5) {
    return BlockFace.SOUTH_WEST;
  } else if (247.5 <= rotation && rotation < 292.5) {
    return BlockFace.WEST;
  } else if (292.5 <= rotation && rotation < 337.5) {
    return BlockFace.NORTH_WEST;
  } else if (337.5 <= rotation && rotation < 360.0) {
    return BlockFace.NORTH;
  } else {
    return BlockFace.NORTH;
  }
}
 
源代码16 项目: AdditionsAPI   文件: PlayerInteract.java
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	PlayerInventory inv = player.getInventory();
	ItemStack item = inv.getItemInMainHand();
	if (event.getHand() != null)
		switch (event.getHand()) {
		case OFF_HAND:
			item = inv.getItemInOffHand();
			break;
		default:
			break;
		}

	if (AdditionsAPI.isCustomItem(item)) {
		CustomItemPlayerInteractEvent customEvent = new CustomItemPlayerInteractEvent(event,
				new CustomItemStack(item));
		Bukkit.getServer().getPluginManager().callEvent(customEvent);
	}
	if (event.getAction() != null && event.getAction() == Action.RIGHT_CLICK_BLOCK
			&& ToolType.getToolType(item.getType()) != null
			&& ToolType.getToolType(item.getType()).equals(ToolType.HOE)) {
		Block block = event.getClickedBlock();
		Material material = block.getType();
		Location blockLoc = block.getLocation();
		blockLoc.setY(blockLoc.getBlockY() + 1);
		Material materialUp = blockLoc.getBlock().getType();
		@SuppressWarnings("deprecation")
		byte data = block.getData();

		BlockFace face = event.getBlockFace();
		if (materialUp == Material.AIR && (face == BlockFace.UP || face == BlockFace.EAST || face == BlockFace.NORTH
				|| face == BlockFace.SOUTH || face == BlockFace.WEST))
			if (shouldPlaySound(material, item, data, player))
				player.playSound(block.getLocation(), "additionsapi.hoe.till", 1.0F, 1.0F);
	}
}
 
源代码17 项目: Shopkeepers   文件: Utils.java
/**
 * Determines the axis-aligned {@link BlockFace} for the given direction.
 * If modY is zero only {@link BlockFace}s facing horizontal will be returned.
 * This method takes into account that the values for EAST/WEST and NORTH/SOUTH
 * were switched in some past version of bukkit. So it should also properly work
 * with older bukkit versions.
 * 
 * @param modX
 * @param modY
 * @param modZ
 * @return
 */
public static BlockFace getAxisBlockFace(double modX, double modY, double modZ) {
	double xAbs = Math.abs(modX);
	double yAbs = Math.abs(modY);
	double zAbs = Math.abs(modZ);

	if (xAbs >= zAbs) {
		if (xAbs >= yAbs) {
			if (modX >= 0.0D) {
				// EAST/WEST and NORTH/SOUTH values were switched in some past bukkit version:
				// with this additional checks it should work across different versions
				if (BlockFace.EAST.getModX() == 1) {
					return BlockFace.EAST;
				} else {
					return BlockFace.WEST;
				}
			} else {
				if (BlockFace.EAST.getModX() == 1) {
					return BlockFace.WEST;
				} else {
					return BlockFace.EAST;
				}
			}
		} else {
			if (modY >= 0.0D) {
				return BlockFace.UP;
			} else {
				return BlockFace.DOWN;
			}
		}
	} else {
		if (zAbs >= yAbs) {
			if (modZ >= 0.0D) {
				if (BlockFace.SOUTH.getModZ() == 1) {
					return BlockFace.SOUTH;
				} else {
					return BlockFace.NORTH;
				}
			} else {
				if (BlockFace.SOUTH.getModZ() == 1) {
					return BlockFace.NORTH;
				} else {
					return BlockFace.SOUTH;
				}
			}
		} else {
			if (modY >= 0.0D) {
				return BlockFace.UP;
			} else {
				return BlockFace.DOWN;
			}
		}
	}
}
 
源代码18 项目: ShopChest   文件: Shop.java
private Location getHologramLocation(Chest[] chests, BlockFace face) {
    World w = location.getWorld();
    int x = location.getBlockX();
    int y  = location.getBlockY();
    int z = location.getBlockZ();

    Location holoLocation = new Location(w, x, y, z);

    double deltaY = -0.6;

    if (Config.hologramFixedBottom) deltaY = -0.85;

    if (chests[1] != null) {
        Chest c1 = Utils.getMajorVersion() >= 13 && (face == BlockFace.NORTH || face == BlockFace.EAST) ? chests[1] : chests[0];
        Chest c2 = Utils.getMajorVersion() >= 13 && (face == BlockFace.NORTH || face == BlockFace.EAST) ? chests[0] : chests[1];

        if (holoLocation.equals(c1.getLocation())) {
            if (c1.getX() != c2.getX()) {
                holoLocation.add(0, deltaY, 0.5);
            } else if (c1.getZ() != c2.getZ()) {
                holoLocation.add(0.5, deltaY, 0);
            } else {
                holoLocation.add(0.5, deltaY, 0.5);
            }
        } else {
            if (c1.getX() != c2.getX()) {
                holoLocation.add(1, deltaY, 0.5);
            } else if (c1.getZ() != c2.getZ()) {
                holoLocation.add(0.5, deltaY, 1);
            } else {
                holoLocation.add(0.5, deltaY, 0.5);
            }
        }
    } else {
        holoLocation.add(0.5, deltaY, 0.5);
    }

    holoLocation.add(0, Config.hologramLift, 0);

    return holoLocation;
}
 
源代码19 项目: Kettle   文件: Sign.java
/**
 * Gets the direction that this sign is currently facing
 *
 * @return BlockFace indicating where this sign is facing
 */
public BlockFace getFacing() {
    byte data = getData();

    if (!isWallSign()) {
        switch (data) {
            case 0x0:
                return BlockFace.SOUTH;

            case 0x1:
                return BlockFace.SOUTH_SOUTH_WEST;

            case 0x2:
                return BlockFace.SOUTH_WEST;

            case 0x3:
                return BlockFace.WEST_SOUTH_WEST;

            case 0x4:
                return BlockFace.WEST;

            case 0x5:
                return BlockFace.WEST_NORTH_WEST;

            case 0x6:
                return BlockFace.NORTH_WEST;

            case 0x7:
                return BlockFace.NORTH_NORTH_WEST;

            case 0x8:
                return BlockFace.NORTH;

            case 0x9:
                return BlockFace.NORTH_NORTH_EAST;

            case 0xA:
                return BlockFace.NORTH_EAST;

            case 0xB:
                return BlockFace.EAST_NORTH_EAST;

            case 0xC:
                return BlockFace.EAST;

            case 0xD:
                return BlockFace.EAST_SOUTH_EAST;

            case 0xE:
                return BlockFace.SOUTH_EAST;

            case 0xF:
                return BlockFace.SOUTH_SOUTH_EAST;
        }

        return null;
    } else {
        return getAttachedFace().getOppositeFace();
    }
}
 
源代码20 项目: UhcCore   文件: DragonRushListener.java
@Override
public void onEnable(){
    if (!GameManager.getGameManager().getConfiguration().getEnableTheEnd()){
        Bukkit.broadcastMessage(ChatColor.RED + "[UhcCore] For DragonRush the end needs to be enabled first!");
        getScenarioManager().removeScenario(Scenario.DRAGONRUSH);
        return;
    }

    Location portalLoc = getPortalLocation();

    portalBlocks.add(portalLoc.clone().add(1, 0, 2).getBlock());
    portalBlocks.add(portalLoc.clone().add(0, 0, 2).getBlock());
    portalBlocks.add(portalLoc.clone().add(-1, 0, 2).getBlock());

    portalBlocks.add(portalLoc.clone().add(-2, 0, 1).getBlock());
    portalBlocks.add(portalLoc.clone().add(-2, 0, 0).getBlock());
    portalBlocks.add(portalLoc.clone().add(-2, 0, -1).getBlock());

    portalBlocks.add(portalLoc.clone().add(1, 0, -2).getBlock());
    portalBlocks.add(portalLoc.clone().add(0, 0, -2).getBlock());
    portalBlocks.add(portalLoc.clone().add(-1, 0, -2).getBlock());

    portalBlocks.add(portalLoc.clone().add(2, 0, 1).getBlock());
    portalBlocks.add(portalLoc.clone().add(2, 0, 0).getBlock());
    portalBlocks.add(portalLoc.clone().add(2, 0, -1).getBlock());

    int i = 0;
    BlockFace blockFace = BlockFace.NORTH;
    for (Block block : portalBlocks){
        block.setType(UniversalMaterial.END_PORTAL_FRAME.getType());
        VersionUtils.getVersionUtils().setEndPortalFrameOrientation(block, blockFace);
        if (RandomUtils.randomInteger(0, 2) == 1){
            VersionUtils.getVersionUtils().setEye(block, true);
        }
        i++;
        if (i == 3){
            i = 0;
            if (blockFace == BlockFace.NORTH){
                blockFace = BlockFace.EAST;
            }else if (blockFace == BlockFace.EAST){
                blockFace = BlockFace.SOUTH;
            }else if (blockFace == BlockFace.SOUTH){
                blockFace = BlockFace.WEST;
            }
        }
    }
}