Java Code Examples for org.bukkit.block.BlockFace#getModX()

The following examples show how to use org.bukkit.block.BlockFace#getModX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnglePattern.java    From AACAdditionPro with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected int process(User user, BlockPlaceEvent event)
{
    final BlockFace placedFace = event.getBlock().getFace(event.getBlockAgainst());
    final Vector placedVector = new Vector(placedFace.getModX(), placedFace.getModY(), placedFace.getModZ());

    // If greater than 90
    if (user.getPlayer().getLocation().getDirection().angle(placedVector) > MAX_ANGLE) {
        if (++user.getScaffoldData().angleFails >= this.violationThreshold) {
            message = "Scaffold-Verbose | Player: " + user.getPlayer().getName() + " placed a block with a suspicious angle.";
            return 3;
        }
    }
    else if (user.getScaffoldData().angleFails > 0) {
        user.getScaffoldData().angleFails--;
    }
    return 0;
}
 
Example 2
Source File: MiscUtils.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Vector getDirection(BlockFace face) {
	int modX = face.getModX();
	int modY = face.getModY();
	int modZ = face.getModZ();
    Vector direction = new Vector(modX, modY, modZ);
    if (modX != 0 || modY != 0 || modZ != 0) {
        direction.normalize();
    }
    return direction;
}
 
Example 3
Source File: MiscUtils.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Vector getDirection(BlockFace face) {
	int modX = face.getModX();
	int modY = face.getModY();
	int modZ = face.getModZ();
    Vector direction = new Vector(modX, modY, modZ);
    if (modX != 0 || modY != 0 || modZ != 0) {
        direction.normalize();
    }
    return direction;
}
 
Example 4
Source File: CancellableChunkEvents.java    From ClaimChunk with MIT License 5 votes vote down vote up
@EventHandler
public void onLiquidPlacePickup(PlayerBucketEmptyEvent e) {
    if (e != null) {
        BlockFace bf = e.getBlockFace();
        Vector v = new Vector(bf.getModX(), bf.getModY(), bf.getModZ());
        ChunkEventHelper.handleBlockEvent(e.getPlayer(), e.getBlockClicked().getLocation().add(v).getChunk(), e);
    }
}
 
Example 5
Source File: CancellableChunkEvents.java    From ClaimChunk with MIT License 5 votes vote down vote up
@EventHandler
public void onLiquidPlacePickup(PlayerBucketFillEvent e) {
    if (e != null) {
        BlockFace bf = e.getBlockFace();
        Vector v = new Vector(bf.getModX(), bf.getModY(), bf.getModZ());
        ChunkEventHelper.handleBlockEvent(e.getPlayer(), e.getBlockClicked().getLocation().add(v).getChunk(), e);
    }
}
 
Example 6
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFace(final Block block) {
    BlockFace[] values = BlockFace.values();

    for (BlockFace face : values) {
        if ((this.getX() + face.getModX() == block.getX()) &&
            (this.getY() + face.getModY() == block.getY()) &&
            (this.getZ() + face.getModZ() == block.getZ())
        ) {
            return face;
        }
    }

    return null;
}
 
Example 7
Source File: AsyncBlock.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BlockFace getFace(Block block) {
    BlockFace[] directions = BlockFace.values();
    for(int i = 0; i < directions.length; ++i) {
        BlockFace face = directions[i];
        if(this.getX() + face.getModX() == block.getX() && this.getY() + face.getModY() == block.getY() && this.getZ() + face.getModZ() == block.getZ()) {
            return face;
        }
    }
    return null;
}
 
Example 8
Source File: BlockFaces.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
static BlockVector getRelative(BlockVector pos, BlockFace face) {
  return new BlockVector(
      pos.getBlockX() + face.getModX(),
      pos.getBlockY() + face.getModY(),
      pos.getBlockZ() + face.getModZ());
}
 
Example 9
Source File: BlockFaces.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static BlockVector getRelative(BlockVector pos, BlockFace face) {
    return new BlockVector(pos.getBlockX() + face.getModX(),
                           pos.getBlockY() + face.getModY(),
                           pos.getBlockZ() + face.getModZ());
}
 
Example 10
Source File: BukkitImageViewer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public void selectFrame(ItemFrame start) {
    Location pos1 = start.getLocation().clone();
    Location pos2 = start.getLocation().clone();

    BlockFace facing = start.getFacing();
    int planeX = facing.getModX() == 0 ? 1 : 0;
    int planeY = facing.getModY() == 0 ? 1 : 0;
    int planeZ = facing.getModZ() == 0 ? 1 : 0;

    ItemFrame[][] res = find(pos1, pos2, facing);
    Location tmp;
    while (true) {
        if (res != null) {
            frames = res;
        }
        tmp = pos1.clone().subtract(planeX, planeY, planeZ);
        if ((res = find(tmp, pos2, facing)) != null) {
            pos1 = tmp;
            continue;
        }
        tmp = pos2.clone().add(planeX, planeY, planeZ);
        if ((res = find(pos1, tmp, facing)) != null) {
            pos2 = tmp;
            continue;
        }
        tmp = pos1.clone().subtract(planeX, 0, planeZ);
        if ((res = find(tmp, pos2, facing)) != null) {
            pos1 = tmp;
            continue;
        }
        tmp = pos2.clone().add(planeX, 0, planeZ);
        if ((res = find(pos1, tmp, facing)) != null) {
            pos2 = tmp;
            continue;
        }
        tmp = pos1.clone().subtract(0, 1, 0);
        if ((res = find(tmp, pos2, facing)) != null) {
            pos1 = tmp;
            continue;
        }
        tmp = pos2.clone().add(0, 1, 0);
        if ((res = find(pos1, tmp, facing)) != null) {
            pos2 = tmp;
            continue;
        }
        break;
    }
}