本文整理汇总了Java中org.bukkit.block.BlockFace类的典型用法代码示例。如果您正苦于以下问题:Java BlockFace类的具体用法?Java BlockFace怎么用?Java BlockFace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockFace类属于org.bukkit.block包,在下文中一共展示了BlockFace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerMove
import org.bukkit.block.BlockFace; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
final Player player = event.getPlayer();
final Material from = event.getFrom().getBlock().getRelative(BlockFace.DOWN).getType();
final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();
final long current = System.currentTimeMillis();
if (player.isSprinting()) {
behaviour.getMotion().setLastSprint(current);
}
if (player.isFlying()) {
behaviour.getMotion().setLastFly(current);
}
if (from.isSolid() || behaviour.getMotion().getLastY() == -1.0 || !behaviour.getMotion().isDescending()) {
behaviour.getMotion().setLastY(player.getLocation().getY());
}
if (!behaviour.isOnGround()) {
behaviour.getMotion().setLastYDiff(event.getTo().getY() - event.getFrom().getY());
}
}
示例2: downElevator
import org.bukkit.block.BlockFace; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void downElevator(PlayerToggleSneakEvent e) {
Player p = e.getPlayer();
Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
if (!p.isSneaking() && b.getType() == elevatorMaterial) {
b = b.getRelative(BlockFace.DOWN, minElevation);
int i = maxElevation; //16
while (i > 0 && !(b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent())) {
i--;
b = b.getRelative(BlockFace.DOWN);
}
if (i > 0) {
Location l = p.getLocation();
l.setY(l.getY() - maxElevation - 2 + i);
p.teleport(l);
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
}
}
}
示例3: onBlockBreak
import org.bukkit.block.BlockFace; //导入依赖的package包/类
/**
* So far specifically handles these cases:
*
* 1) Block broken is tracked
* 2) Block breaks by not-players
* 3) Block breaks by players
* 4) Indirect block breaks -- destroying block supporting a crop or collapsible tree, or under mushrooms
* 5) Indirect block break of cocoa bearing logs
* 6) Block broken had mushroom on top and cocoa on the sides
*
* @param e The event
*/
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
Player player = e.getPlayer();
BreakType type = player != null ? BreakType.PLAYER : BreakType.NATURAL;
UUID uuid = player != null ? player.getUniqueId() : null;
if (maybeSideTracked(block)) {
trySideBreak(block, type, uuid);
}
if (maybeBelowTracked(block)) {
block = block.getRelative(BlockFace.UP);
}
Location loc = block.getLocation();
if (!pendingChecks.contains(loc)) {
pendingChecks.add(loc);
handleBreak(block, type, uuid, null);
}
}
示例4: onBlockBurn
import org.bukkit.block.BlockFace; //导入依赖的package包/类
/**
* So far specifically handles these cases:
*
* 1) Block burnt is tracked
* 2) Block burnt is under a tracked block (probably only mushrooms eligible)
* 3) Block burnt was a jungle tree, checks for cocoa.
* 4) Burnt block had mushroom on top and cocoa on the sides
*
* @param e The event
*/
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent e) {
Block block = e.getBlock();
if (maybeSideTracked(block)) {
trySideBreak(block, BreakType.FIRE, null);
}
if (maybeBelowTracked(block)) {
block = block.getRelative(BlockFace.UP);
}
Location loc = block.getLocation();
if (!pendingChecks.contains(loc)) {
pendingChecks.add(loc);
handleBreak(block, BreakType.FIRE, null, null);
}
}
示例5: notchToBlockFace
import org.bukkit.block.BlockFace; //导入依赖的package包/类
/**
* Notch uses a 0-5 to mean DOWN, UP, NORTH, SOUTH, WEST, EAST
* in that order all over. This method is convenience to convert for us.
*
* @return BlockFace the BlockFace represented by this number
*/
public static BlockFace notchToBlockFace(int notch) {
switch (notch) {
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;
}
}
示例6: blockFaceToNotch
import org.bukkit.block.BlockFace; //导入依赖的package包/类
public static int blockFaceToNotch(BlockFace face) {
switch (face) {
case DOWN:
return 0;
case UP:
return 1;
case NORTH:
return 2;
case SOUTH:
return 3;
case WEST:
return 4;
case EAST:
return 5;
default:
return 7; // Good as anything here, but technically invalid
}
}
示例7: isShopBlockNearby
import org.bukkit.block.BlockFace; //导入依赖的package包/类
private boolean isShopBlockNearby(Block b) {
if (b == null) {
return false;
}
Block nearChest = null;
if (b.getType() == Material.CHEST) {
nearChest = getBlockNearby(b, Material.CHEST);
} else if (b.getType() == Material.TRAPPED_CHEST) {
nearChest = getBlockNearby(b, Material.TRAPPED_CHEST);
}
if (nearChest == null) {
return false;
}
for (BlockFace face : BLOCKFACE) {
Block maybeSign = nearChest.getRelative(face);
if (maybeSign != null && Material.WALL_SIGN == maybeSign.getType()) {
Sign sign = (Sign) maybeSign.getState();
if (sign.getLines().length > 0 && sign.getLines()[0].contains(cm.quickshopSignFlag)) {
return true;
}
}
}
return false;
}
示例8: TreeGrowChecker
import org.bukkit.block.BlockFace; //导入依赖的package包/类
@EventHandler
public void TreeGrowChecker(StructureGrowEvent event) {
if (ConfigPatch.safetyBonemeal) {
if(event.isFromBonemeal() == false) {
return;
}
List<BlockState> blocks = event.getBlocks();
int bs = blocks.size();
for(int i = 0;i<bs;i++){
Block block = blocks.get(i).getBlock();
if(block.getType() != Material.AIR && block.getType() != Material.SAPLING && block.getType() != event.getLocation().getBlock().getRelative(BlockFace.DOWN).getType()){
event.setCancelled(true);
if (event.getPlayer() != null) {
AzureAPI.log(event.getPlayer(), "§c这棵树生长区域有方块阻挡,请不要尝试利用骨粉BUG!");
return;
}
}
}
}
}
示例9: onPlayerMove
import org.bukkit.block.BlockFace; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
if(event.getTo().getY() <= Integer.valueOf((String) this.getGameMap().fetchSetting("floorLevel"))) {
this.getAPI().getGameManager().setAlive(event.getPlayer(), false);
} else {
final Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
if(block.getType() != Material.AIR) {
if(!pendingDeletion.contains(block)) {
pendingDeletion.add(block);
new BukkitRunnable() {
public void run() {
if(pendingDeletion.contains(block)) {
block.setType(Material.AIR);
pendingDeletion.remove(block);
}
}
}.runTaskLater(this.getAPI().getPlugin(), 3L);
}
}
}
}
}
示例10: send
import org.bukkit.block.BlockFace; //导入依赖的package包/类
@Override
public void send(Player p) {
if (direction == BlockFace.UP || direction == BlockFace.DOWN) {
new CircleForm(getLocation(), "y", getDense(), getRadius(), getAction()).send(p);
new CircleForm(getLocation().clone().add(0, getDepth(), 0), "y", getDense(), getRadius(), getAction()).send(p);
for (double d = getDense(); d < getDepth() - getDense(); d += getDense())
new CircleForm(getLocation().clone().add(0, d, 0), "y", getDense(), getRadius(), getAction()).send(p);
} else if (direction == BlockFace.EAST || direction == BlockFace.WEST) {
new CircleForm(getLocation(), "z", getDense(), getRadius(), getAction()).send(p);
new CircleForm(getLocation().clone().add(getDepth(), 0, 0), "z", getDense(), getRadius(), getAction()).send(p);
for (double d = getDense(); d < getDepth() - getDense(); d += getDense())
new CircleForm(getLocation().clone().add(d, 0, 0), "z", getDense(), getRadius(), getAction()).send(p);
} else {
new CircleForm(getLocation(), "x", getDense(), getRadius(), getAction()).send(p);
new CircleForm(getLocation().clone().add(0, 0, getDepth()), "x", getDense(), getRadius(), getAction()).send(p);
for (double d = getDense(); d < getDepth() - getDense(); d += getDense())
new CircleForm(getLocation().clone().add(0, 0, d), "x", getDense(), getRadius(), getAction()).send(p);
}
}
示例11: 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));
}
示例12: 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));
}
示例13: isIllegallyOutsideLane
import org.bukkit.block.BlockFace; //导入依赖的package包/类
private static boolean isIllegallyOutsideLane(Region lane, Location loc) {
Block feet = loc.getBlock();
if(feet == null) return false;
if(isIllegalBlock(lane, feet)) {
return true;
}
Block head = feet.getRelative(BlockFace.UP);
if(head == null) return false;
if(isIllegalBlock(lane, head)) {
return true;
}
return false;
}
示例14: canDropAt
import org.bukkit.block.BlockFace; //导入依赖的package包/类
public boolean canDropAt(Location location) {
if(!match.getWorld().equals(location.getWorld())) return false;
Block block = location.getBlock();
Block below = block.getRelative(BlockFace.DOWN);
if(!canDropOn(below.getState())) return false;
if(block.getRelative(BlockFace.UP).getType() != Material.AIR) return false;
switch(block.getType()) {
case AIR:
case LONG_GRASS:
return true;
default:
return false;
}
}
示例15: onHopperPickup
import org.bukkit.block.BlockFace; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true) // Handles special items entering hoppers.
public void onHopperPickup(InventoryPickupItemEvent evt) {
if (!(evt.getInventory().getHolder() instanceof Hopper))
return; // Verify the inventory the item is going to enter is a hopper.
Hopper hp = (Hopper) evt.getInventory().getHolder();
Matcher mName = Pattern.compile("<Custom ID: (\\w+)>").matcher(hp.getInventory().getName());
if (!mName.find())
return; // If it doesn't have a Custom item ID defined, don't handle it.
ItemWrapper iw = ItemManager.constructItem(evt.getItem().getItemStack());
evt.setCancelled(true);
if (mName.group(1).equalsIgnoreCase(iw.getTagString("id"))) { // We've found the right item! Consume it.
evt.getItem().remove();
hp.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK);
} else { // This item isn't acceptable, spit it back out.
evt.getItem().setVelocity(new Vector(0, .15F, 0));
}
}