本文整理汇总了Java中org.bukkit.block.BlockFace.NORTH属性的典型用法代码示例。如果您正苦于以下问题:Java BlockFace.NORTH属性的具体用法?Java BlockFace.NORTH怎么用?Java BlockFace.NORTH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.block.BlockFace
的用法示例。
在下文中一共展示了BlockFace.NORTH属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notchToBlockFace
/**
* 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;
}
}
示例2: send
@Override
public void send(Player p) {
if (direction == BlockFace.UP) {
for (double r = basis; r > 0 && size != 0; r -= getDense(), size -= getDense())
new RectangleForm(getLocation().clone().subtract(0, r, 0), "y", getDense(), r, r, isFilled(), getAction()).send(p);
} else if (direction == BlockFace.EAST) {
for (double r = basis; r > 0 && size != 0; r -= getDense(), size -= getDense())
new RectangleForm(getLocation().clone().subtract(r, 0, 0), "z", getDense(), r, r, isFilled(), getAction()).send(p);
} else if (direction == BlockFace.WEST) {
for (double r = basis; r > 0 && size != 0; r -= getDense(), size -= getDense())
new RectangleForm(getLocation().clone().add(r, 0, 0), "z", getDense(), r, r, isFilled(), getAction()).send(p);
} else if (direction == BlockFace.SOUTH) {
for (double r = basis; r > 0 && size != 0; r -= getDense(), size -= getDense())
new RectangleForm(getLocation().clone().subtract(0, 0, r), "x", getDense(), r, r, isFilled(), getAction()).send(p);
} else if (direction == BlockFace.NORTH) {
for (double r = basis; r > 0 && size != 0; r -= getDense(), size -= getDense())
new RectangleForm(getLocation().clone().add(0, 0, r), "x", getDense(), r, r, isFilled(), getAction()).send(p);
} else {
for (double r = basis; r > 0 && size != 0; r -= getDense(), size -= getDense())
new RectangleForm(getLocation().clone().add(0, r, 0), "y", getDense(), r, r, isFilled(), getAction()).send(p);
}
}
示例3: send
@Override
public void send(Player p) {
if (direction == BlockFace.UP) {
for (double r = baseRadius; r > 0 && size != 0; r -= getDense(), size -= getDense())
new CircleForm(getLocation().clone().subtract(0, r, 0), "y", getDense(), r, getAction()).send(p);
} else if (direction == BlockFace.EAST) {
for (double r = baseRadius; r > 0 && size != 0; r -= getDense(), size -= getDense())
new CircleForm(getLocation().clone().subtract(r, 0, 0), "z", getDense(), r, getAction()).send(p);
} else if (direction == BlockFace.WEST) {
for (double r = baseRadius; r > 0 && size != 0; r -= getDense(), size -= getDense())
new CircleForm(getLocation().clone().add(r, 0, 0), "z", getDense(), r, getAction()).send(p);
} else if (direction == BlockFace.SOUTH) {
for (double r = baseRadius; r > 0 && size != 0; r -= getDense(), size -= getDense())
new CircleForm(getLocation().clone().subtract(0, 0, r), "x", getDense(), r, getAction()).send(p);
} else if (direction == BlockFace.NORTH) {
for (double r = baseRadius; r > 0 && size != 0; r -= getDense(), size -= getDense())
new CircleForm(getLocation().clone().add(0, 0, r), "x", getDense(), r, getAction()).send(p);
} else {
for (double r = baseRadius; r > 0 && size != 0; r -= getDense(), size -= getDense())
new CircleForm(getLocation().clone().add(0, r, 0), "y", getDense(), r, getAction()).send(p);
}
}
示例4: getFacing
public BlockFace getFacing() {
switch (this.getHandle().hangingDirection) {
case 0:
default:
return BlockFace.SOUTH;
case 1:
return BlockFace.WEST;
case 2:
return BlockFace.NORTH;
case 3:
return BlockFace.EAST;
}
}
示例5: getBlockPower
public int getBlockPower(BlockFace face) {
int power = 0;
BlockRedstoneWire wire = Blocks.redstone_wire;
net.minecraft.world.World world = chunk.getHandle().worldObj;
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y - 1, z, 0)) power = wire.func_150178_a(world, x, y - 1, z, power);
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y + 1, z, 1)) power = wire.func_150178_a(world, x, y + 1, z, power);
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.getIndirectPowerOutput(x + 1, y, z, 2)) power = wire.func_150178_a(world, x + 1, y, z, power);
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.getIndirectPowerOutput(x - 1, y, z, 3)) power = wire.func_150178_a(world, x - 1, y, z, power);
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y, z - 1, 4)) power = wire.func_150178_a(world, x, y, z - 1, power);
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y, z + 1, 5)) power = wire.func_150178_a(world, x, y, z - 1, power);
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
}
示例6: getBlockFace
static BlockFace getBlockFace(byte rotation) {
switch (rotation) {
case 0:
return BlockFace.NORTH;
case 1:
return BlockFace.NORTH_NORTH_EAST;
case 2:
return BlockFace.NORTH_EAST;
case 3:
return BlockFace.EAST_NORTH_EAST;
case 4:
return BlockFace.EAST;
case 5:
return BlockFace.EAST_SOUTH_EAST;
case 6:
return BlockFace.SOUTH_EAST;
case 7:
return BlockFace.SOUTH_SOUTH_EAST;
case 8:
return BlockFace.SOUTH;
case 9:
return BlockFace.SOUTH_SOUTH_WEST;
case 10:
return BlockFace.SOUTH_WEST;
case 11:
return BlockFace.WEST_SOUTH_WEST;
case 12:
return BlockFace.WEST;
case 13:
return BlockFace.WEST_NORTH_WEST;
case 14:
return BlockFace.NORTH_WEST;
case 15:
return BlockFace.NORTH_NORTH_WEST;
default:
throw new AssertionError(rotation);
}
}
示例7: getDirectionFromRelative
public Block getDirectionFromRelative(Block blockIn, BlockFace dir, boolean left)
{
Block b;
if( dir == BlockFace.NORTH )
{
if( left )
b = blockIn.getRelative(BlockFace.WEST);
else
b = blockIn.getRelative(BlockFace.EAST);
}else if( dir == BlockFace.SOUTH )
{
if( left )
b = blockIn.getRelative(BlockFace.EAST);
else
b = blockIn.getRelative(BlockFace.WEST);
}else if( dir == BlockFace.EAST )
{
if( left )
b = blockIn.getRelative(BlockFace.NORTH);
else
b = blockIn.getRelative(BlockFace.SOUTH);
}else //if( direction == BlockFace.WEST )
{
if( left )
b = blockIn.getRelative(BlockFace.SOUTH);
else
b = blockIn.getRelative(BlockFace.NORTH);
}
return b;
}
示例8: getTubeBlockFace
public BlockFace getTubeBlockFace(boolean left)
{
BlockFace bf;
if( direction == BlockFace.NORTH )
{
if( left )
bf = BlockFace.WEST;
else
bf = BlockFace.EAST;
}else if( direction == BlockFace.SOUTH )
{
if( left )
bf = BlockFace.EAST;
else
bf = BlockFace.WEST;
}else if( direction == BlockFace.EAST )
{
if( left )
bf = BlockFace.NORTH;
else
bf = BlockFace.SOUTH;
}else //if( direction == BlockFace.WEST )
{
if( left )
bf = BlockFace.SOUTH;
else
bf = BlockFace.NORTH;
}
return bf;
}
示例9: isGeckBuildCorrect
/**
* Checks if the geck structure is correct.
*
* @param center
* The center block.
* @return true if the build is correct, false otherwise.
*/
public boolean isGeckBuildCorrect(Block center) {
BlockFace[] faces = { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH };
for (BlockFace f : faces) {
if (center.getRelative(f).getType() != Material.PISTON_BASE)
return false;
}
return true;
}
示例10: getBlockFace
public static BlockFace getBlockFace(double yaw){
int y = (int) ((yaw+11.25)/22.5);
switch(y){
case -8:
return BlockFace.NORTH;
case -7:
return BlockFace.NORTH_NORTH_EAST;
case -6:
return BlockFace.NORTH_EAST;
case -5:
return BlockFace.EAST_NORTH_EAST;
case -4:
return BlockFace.EAST;
case -3:
return BlockFace.EAST_SOUTH_EAST;
case -2:
return BlockFace.SOUTH_EAST;
case -1:
return BlockFace.SOUTH_SOUTH_EAST;
case 0:
return BlockFace.SOUTH;
case 1:
return BlockFace.SOUTH_SOUTH_WEST;
case 2:
return BlockFace.SOUTH_WEST;
case 3:
return BlockFace.WEST_SOUTH_WEST;
case 4:
return BlockFace.WEST;
case 5:
return BlockFace.WEST_NORTH_WEST;
case 6:
return BlockFace.NORTH_WEST;
case 7:
return BlockFace.NORTH_NORTH_WEST;
default:
return BlockFace.NORTH;
}
}
示例11: addChunk
private void addChunk(Player player, Region region, String[] args, int i) {
World world = player.getWorld();
Chunk chunk = player.getLocation().getChunk();
int x = chunk.getX();
int z = chunk.getZ();
boolean override = args.length > i + 2 ? args[i + 2].equalsIgnoreCase("-override") : false;
if (region == null) {
ParsingUtil.sendMessage(player, ChatColor.RED + "/f world addChunk [region name] [radius|line|auto] [value] ([-override])");
return;
}
if (args.length >= i + 1) {
if (args[i].equalsIgnoreCase("radius") || args[i].equalsIgnoreCase("r")) {
int r = args.length > i + 1 ? NumberUtil.parseInt(args[i + 1]) : 1;
x += -1 * r;
z += -1 * r;
while (z <= chunk.getZ() + r) {
if (board.isWilderness(world.getChunkAt(x, z)) || override) {
addChunk(region, world.getChunkAt(x, z), override);
}
x++;
if (x > chunk.getX() + r) {
x = chunk.getX() + -1 * r;
z++;
}
}
} else if (args[i].equalsIgnoreCase("line") || args[i].equalsIgnoreCase("l")) {
int l = args.length > i + 1 ? NumberUtil.parseInt(args[i + 1]) : 1;
BlockFace face = AXIS[Math.round(player.getLocation().getYaw() / 90F) & 0x3];
if (face == BlockFace.NORTH) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x, z + l)) || override) {
addChunk(region, world.getChunkAt(x, z + l), override);
}
l--;
}
} else if (face == BlockFace.EAST) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x - l, z)) || override) {
addChunk(region, world.getChunkAt(x - l, z), override);
}
l--;
}
} else if (face == BlockFace.WEST) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x + l, z)) || override) {
addChunk(region, world.getChunkAt(x + l, z), override);
}
l--;
}
} else if (face == BlockFace.SOUTH) {
while (l >= 0) {
if (board.isWilderness(world.getChunkAt(x, z - l)) || override) {
addChunk(region, world.getChunkAt(x, z - l), override);
}
l--;
}
}
} else if (args[i].equalsIgnoreCase("auto") || args[i].equalsIgnoreCase("a")) {
FPlayer fPlayer = plugin.getFPlayerCache().getByPlayer(player);
if (fPlayer.isAutoclaiming()) {
fPlayer.setAutoclaiming(null);
ParsingUtil.sendMessage(player, FMessage.CMD_WORLD_AUTOCLAIM_END.getMessage());
return;
} else {
fPlayer.setAutoclaiming(region);
ParsingUtil.sendMessage(player, FMessage.CMD_WORLD_AUTOCLAIM_START.getMessage(), region);
}
}
} else {
addChunk(region, chunk, override);
}
ParsingUtil.sendMessage(player, FMessage.CMD_WORLD_CHUNK_ADDED.getMessage(), region);
}
示例12: loadTorpedo
@SuppressWarnings("deprecation")
public boolean loadTorpedo(boolean left)
{
Block b;
b = getDirectionFromRelative(loc.getBlock(), direction, left).getRelative(direction, -5);
if( direction == BlockFace.NORTH && left )
b = b.getRelative(BlockFace.WEST);
else if( direction == BlockFace.NORTH && !left )
b = b.getRelative(BlockFace.EAST);
else if( direction == BlockFace.SOUTH && left )
b = b.getRelative(BlockFace.EAST);
else if( direction == BlockFace.SOUTH && !left )
b = b.getRelative(BlockFace.WEST);
else if( direction == BlockFace.EAST && left )
b = b.getRelative(BlockFace.NORTH);
else if( direction == BlockFace.EAST && !left )
b = b.getRelative(BlockFace.SOUTH);
else if( direction == BlockFace.WEST && left )
b = b.getRelative(BlockFace.SOUTH);
else //if( direction == BlockFace.WEST && !left )
b = b.getRelative(BlockFace.NORTH);
for( int i=0; i<4; i++)
{
if( b.getTypeId() == 35 )
if( b.getRelative(direction,-1).getTypeId() == 35 )
if( b.getRelative(direction,-2).getTypeId() == 35 )
if( b.getRelative(direction,-3).getTypeId() == 35 )
{
if( i > 1 )
loadingTorp(left, b, direction, true);
else
loadingTorp(left, b, direction, false);
if( left )
leftLoading = true;
else
rightLoading = true;
Craft testCraft = Craft.getCraft(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
if( testCraft != null )
{
testCraft.waitTorpLoading++;
}
return true;
}
//move back four spaces unless going from 2 to 3, then carriage return it
if( i == 1 )
b = b.getRelative(direction,4).getRelative(BlockFace.DOWN);
else
b = b.getRelative(direction,-4);
}
return false;
}
示例13: fireDCButton
@SuppressWarnings("deprecation")
public void fireDCButton(Player p, boolean leftClick)
{
if( checkProtectedRegion(p, p.getLocation()) )
{
p.sendMessage("You are in a protected region");
return;
}
if( leftClick )
{
if( charged > 0 )
{
if( depth == 0 )
depth = 10;
if( cannonType == 4 )
{
loc.getBlock().getRelative(direction,4).setTypeIdAndData(35, (byte) 0x8, false);
loc.getBlock().getRelative(direction,4).getRelative(BlockFace.DOWN).setTypeIdAndData(35, (byte) 0x8, false);
fireDC(p, loc.getBlock().getRelative(direction,4), depth, loc.getBlockY(), 0, 2);
p.sendMessage("Depth Charge Away!");
}else if( cannonType == 9 )
{
loc.getBlock().getRelative(BlockFace.DOWN,5).setTypeIdAndData(35, (byte) 0x8, false);
loc.getBlock().getRelative(BlockFace.DOWN,5).getRelative(BlockFace.DOWN).setTypeIdAndData(35, (byte) 0x7, false);
fireDC(p, loc.getBlock().getRelative(BlockFace.DOWN,5), 0, loc.getBlock().getRelative(BlockFace.DOWN,5).getY(), 0, 2);
p.sendMessage("Bomb Away!");
}else
{
loc.getBlock().getRelative(direction,4).setTypeIdAndData(35, (byte) 0x8, false);
loc.getBlock().getRelative(direction,4).getRelative(BlockFace.DOWN).setTypeIdAndData(35, (byte) 0x8, false);
fireDC(p, loc.getBlock().getRelative(direction,4), depth, loc.getBlockY(), 0, 0);
if( direction == BlockFace.NORTH || direction == BlockFace.SOUTH )
{
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.EAST,10).setTypeIdAndData(35, (byte) 0x8, false);
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.DOWN).getRelative(BlockFace.EAST,10).setTypeIdAndData(35, (byte) 0x8, false);
fireDC(p, loc.getBlock().getRelative(direction,6).getRelative(BlockFace.EAST,10), depth, loc.getBlockY(), 1000, 1);
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.WEST,10).setTypeIdAndData(35, (byte) 0x8, false);
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.DOWN).getRelative(BlockFace.WEST,10).setTypeIdAndData(35, (byte) 0x8, false);
fireDC(p, loc.getBlock().getRelative(direction,6).getRelative(BlockFace.WEST,10), depth, loc.getBlockY(), 1000, -1);
}else
{
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.NORTH,10).setTypeIdAndData(35, (byte) 0x8, false);
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.DOWN).getRelative(BlockFace.NORTH,10).setTypeIdAndData(35, (byte) 0x8, false);
fireDC(p, loc.getBlock().getRelative(direction,6).getRelative(BlockFace.NORTH,10), depth, loc.getBlockY(), 1000, 1);
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.SOUTH,10).setTypeIdAndData(35, (byte) 0x8, false);
loc.getBlock().getRelative(direction,6).getRelative(BlockFace.DOWN).getRelative(BlockFace.SOUTH,10).setTypeIdAndData(35, (byte) 0x8, false);
fireDC(p, loc.getBlock().getRelative(direction,6).getRelative(BlockFace.SOUTH,10), depth, loc.getBlockY(), 1000, -1);
}
p.sendMessage("Depth Charges Away!");
}
charged = 0;
}else
{
if( cannonType == 4 )
p.sendMessage("Load Depth Charge Dropper first.");
else if( cannonType == 5 )
p.sendMessage("Load Depth Charge Launcher first.");
else
p.sendMessage("Load Bomb Dropper first.");
}
}else
{
depth += 10;
if( depth > 40 )
depth = 10;
if( cannonType == 4 )
p.sendMessage("Depth Charge Dropper set to " + depth + " meters.");
else if( cannonType == 5 )
p.sendMessage("Depth Charge Launcher set to " + depth + " meters.");
else if( cannonType == 9 )
p.sendMessage("Left click to drop bomb.");
}
}
示例14: clientNewSign
public void clientNewSign(ChannelHandlerContext ctx, int x, int y, int z, int face, String text) {
if (!allowSigns) {
webSocketServerThread.sendLine(ctx.channel(), "T,Writing on signs is not allowed");
// TODO: revert on client
return;
}
BlockFace blockFace;
switch (face) {
case 0: // west
blockFace = BlockFace.WEST;
x -= 1;
break;
case 1: // east
blockFace = BlockFace.EAST;
x += 1;
break;
default:
case 2: // north
blockFace = BlockFace.NORTH;
z -= 1;
break;
case 3: // south
blockFace = BlockFace.SOUTH;
z += 1;
break;
}
org.bukkit.material.Sign signDirection = new org.bukkit.material.Sign();
signDirection.setFacingDirection(blockFace);
Location location = toBukkitLocation(x, y, z);
if (!withinSandboxRange(location)) {
webSocketServerThread.log(Level.FINEST, "client tried to write a sign outside sandbox range");
return;
}
// Create the sign
Block block = location.getWorld().getBlockAt(location);
/*
block.setTypeIdAndData(Material.WALL_SIGN.getId(), data, applyPhysics);
webSocketServerThread.log(Level.FINEST, "setting sign at "+location+" data="+data);
*/
BlockState blockState = block.getState();
blockState.setType(Material.WALL_SIGN);
blockState.setData(signDirection);
boolean force = true;
boolean applyPhysics = false;
blockState.update(force, applyPhysics);
webSocketServerThread.log(Level.FINEST, "setting sign at "+location+" blockFace="+blockFace);
// Set the sign text
blockState = block.getState();
if (!(blockState instanceof Sign)) {
webSocketServerThread.log(Level.WARNING, "failed to place sign at "+location);
return;
}
Sign sign = (Sign) blockState;
// TODO: text lines by 15 characters into 5 lines
sign.setLine(0, text);
sign.update(force, applyPhysics);
webSocketServerThread.log(Level.FINEST, "set sign text="+text+", signDirection="+signDirection+", blockFace="+blockFace+", block="+block+", face="+face);
// SignChangeEvent not posted when signs created programmatically; notify web clients ourselves
notifySignChange(location, block.getType(), block.getState(), sign.getLines());
}
示例15: onDispenseEquip
@EventHandler
public void onDispenseEquip(BlockDispenseEvent event) {
ArmorType type = ArmorType.matchType(event.getItem());
if (type != null) {
Location blockLoc = event.getBlock().getLocation();
for (Player player : blockLoc.getWorld().getPlayers()) {
Location playerLoc = player.getLocation();
if (blockLoc.getBlockY() - playerLoc.getBlockY() >= -1
&& blockLoc.getBlockY() - playerLoc.getBlockY() <= 1) {
if (type == ArmorType.HELMET && player.getInventory().getHelmet() == null
|| type == ArmorType.CHESTPLATE && player.getInventory().getChestplate() == null
|| type == ArmorType.LEGGINGS && player.getInventory().getLeggings() == null
|| type == ArmorType.BOOTS && player.getInventory().getBoots() == null) {
org.bukkit.block.Dispenser dispenser = (org.bukkit.block.Dispenser) event.getBlock().getState();
org.bukkit.material.Dispenser dis = (org.bukkit.material.Dispenser) dispenser.getData();
BlockFace directionFacing = dis.getFacing();
// Someone told me not to do big if checks because it's hard to read, look at me doing it -_-
if (directionFacing == BlockFace.EAST && playerLoc.getBlockX() != blockLoc.getBlockX()
&& playerLoc.getX() <= blockLoc.getX() + 2.3 && playerLoc.getX() >= blockLoc.getX()
|| directionFacing == BlockFace.WEST && playerLoc.getX() >= blockLoc.getX() - 1.3
&& playerLoc.getX() <= blockLoc.getX()
|| directionFacing == BlockFace.SOUTH
&& playerLoc.getBlockZ() != blockLoc.getBlockZ()
&& playerLoc.getZ() <= blockLoc.getZ() + 2.3 && playerLoc.getZ() >= blockLoc.getZ()
|| directionFacing == BlockFace.NORTH && playerLoc.getZ() >= blockLoc.getZ() - 1.3
&& playerLoc.getZ() <= blockLoc.getZ()) {
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
Slot armorSlot = SlotManager.instance().getSlot(type.name());
event.setCancelled(armorSlot != null
&& !InventoryManager.validateArmor(
player, InventoryAction.PLACE_ONE, armorSlot, event.getItem()));
return;
}
}
}
}
}
}